Skip to content

Commit feb674c

Browse files
authored
Update README.md
1 parent 4ff9509 commit feb674c

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,81 @@
1-
# retrofit-kotlin-upload-progress
1+
Retrofit Request Body With Progress(Kotlin)
2+
========================
3+
4+
## Introduction
5+
This library allows you to get upload progress from [Retrofit][1] Request Body
6+
7+
Support
8+
-----
9+
✅ Single File Upload <br/>
10+
✅ Multiple File Upload
11+
12+
Usage
13+
-----
14+
15+
This library allows you to specify your service interface as:
16+
```kotlin
17+
interface Service {
18+
@POST("/posts")
19+
fun createPost(@Body body: RequestBody): Response<Post>
20+
}
21+
```
22+
23+
And then in your repository:
24+
```kotlin
25+
val bodyBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
26+
27+
bodyBuilder.addFormDataPart("title", "Post Title")
28+
bodyBuilder.addFormDataPart("description", "Post Description")
29+
30+
//File
31+
bodyBuilder.addFormDataPart("image", file.name, file.asRequestBody("image/*".toMediaTypeOrNull()))
32+
bodyBuilder.addFormDataPart("video", file.name, file.asRequestBody("video/*".toMediaTypeOrNull()))
33+
34+
val requestBody = bodyBuilder.build()
35+
val requestBodyWithProgress = ReqBodyWithProgress(requestBody){progress ->
36+
//If you use logging interceptor this will trigger twice
37+
Log.d("Upload Progress:",""+progress)
38+
}
39+
40+
val call = service.createPost(requestBodyWithProgress)
41+
```
42+
43+
## Setup
44+
45+
Currently available via [JitPack][2].
46+
47+
To use it, add the jitpack maven repository to your `build.gradle` file:
48+
```gradle
49+
repositories {
50+
...
51+
maven { url "https://jitpack.io" }
52+
...
53+
}
54+
```
55+
and add the dependency:
56+
```gradle
57+
dependencies {
58+
...
59+
implementation 'com.github.Musfick:retrofit-kotlin-upload-progress:0.1.0'
60+
...
61+
}
62+
```
63+
64+
## License
65+
66+
Copyright 2021 Musfick Jamil
67+
68+
Licensed under the Apache License, Version 2.0 (the "License");
69+
you may not use this file except in compliance with the License.
70+
You may obtain a copy of the License at
71+
72+
http://www.apache.org/licenses/LICENSE-2.0
73+
74+
Unless required by applicable law or agreed to in writing, software
75+
distributed under the License is distributed on an "AS IS" BASIS,
76+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77+
See the License for the specific language governing permissions and
78+
limitations under the License.
79+
80+
[1]: http://square.github.io/retrofit/
81+
[2]: https://jitpack.io

0 commit comments

Comments
 (0)