Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maiconhellmann/20d4973679c859c80be690420e959220 to your computer and use it in GitHub Desktop.
Save maiconhellmann/20d4973679c859c80be690420e959220 to your computer and use it in GitHub Desktop.
Send image or file multipart retrofit RxJava
//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