Created
March 11, 2018 12:10
-
-
Save maiconhellmann/20d4973679c859c80be690420e959220 to your computer and use it in GitHub Desktop.
Send image or file multipart retrofit RxJava
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Preparing the request | |
val filePart = MultipartBody.Part | |
.createFormData("file", "fileName", | |
RequestBody.create(MediaType.parse("image/jpeg"), File("/your/File/Path.jpg"))) | |
//service.sendFile(id, filePart) | |
//Request definition retrofit | |
@PUT("https://www.yourdomain.com/api/file/{id}") | |
@Multipart | |
fun sendFile(@Path("id") id: Long, @Part file: MultipartBody.Part ) : Observable<YourModel> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment