Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created January 22, 2018 10:43
Show Gist options
  • Save ar-android/972938c3b380f1f1c29a962f3309804d to your computer and use it in GitHub Desktop.
Save ar-android/972938c3b380f1f1c29a962f3309804d to your computer and use it in GitHub Desktop.
Loop array images request body
MultipartBody.Builder builder = new MultipartBody.Builder();
MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
int i = 0;
for (Image imageData : listImage) {
builder.addFormDataPart("uploaded_file" + "["+ i +"]", imageData.getName(), RequestBody.create(MEDIA_TYPE_PNG, new File(imageData.getPath())));
i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment