Skip to content

Instantly share code, notes, and snippets.

@AndSky90
Last active November 4, 2019 13:49
Show Gist options
  • Save AndSky90/c41313218c4798084a8ba0a06a81edaf to your computer and use it in GitHub Desktop.
Save AndSky90/c41313218c4798084a8ba0a06a81edaf to your computer and use it in GitHub Desktop.
Multipart jpg file
val b = BitmapFactory.decodeFile(filePath)
val stream = ByteArrayOutputStream()
b.compress(Bitmap.CompressFormat.JPEG, 100, stream)
val ba = stream.toByteArray()
photoPart = RequestBody.create(MediaType.parse("image/jpeg"), ba)
body = MultipartBody.Part.createFormData("Photo", "Photo.jpg", photoPart!!)
val part = RequestBody.create(MediaType.parse("text/plain"), text)
@Multipart
@PUT("$CURRENT_API/Endpoint/")
fun putProfile(
@Part("Text") name: RequestBody,
@Part image: MultipartBody.Part?,
): Observable<ResponseData<String>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment