Last active
January 14, 2019 11:48
-
-
Save rezaiyan/445d49379fffafe5dee4e2d02cf147bc to your computer and use it in GitHub Desktop.
Upload file with retrofit
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
// Activity | |
val file = File(path) | |
val requestFile = RequestBody.create(MediaType.parse(context.contentResolver.getType(data.data)), file) | |
val body = MultipartBody.Part.createFormData("avatar", file.name, requestFile) | |
presenter.uploadUserAvatar(body) | |
// Activity | |
// Endpoint.kt | |
@Multipart | |
@POST(Const.URL.USER_AVATAR_UPDATE) | |
fun uploadAvatar( @Part file: MultipartBody.Part): Observable<GetAvatarModel> | |
// Endpoint.kt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment