1

Hello guys i am using retrofit with android and also laravel 5.1 for file uploading on the server side now the problem i am facing is that in retrofit i want to send multiple images with same name on the server side and catch them as that name.

Example input using postman:

enter image description here

If anyone know anything about this please comment, post :)

Thanks Anyways

Alex
  • 8,461
  • 6
  • 37
  • 49
Wandy Liem
  • 49
  • 1
  • 9

1 Answers1

0

I would be happy and delighted if this could help you as well.

Server API contract : Input Type : Multipart-from data

Data to be send in body against key called "images"

@POST("feeds")
Call<> createFeeds(@Body RequestBody file);


 MultipartBody.Builder builder = new MultipartBody.Builder();
    builder.setType(MultipartBody.FORM);
    builder.addFormDataPart("content", textContent);

    for(String filePath : imagePathList){
        File file = new File(filePath);
        builder.addFormDataPart("images", file.getName(),
                RequestBody.create(MediaType.parse("image/*"), file));
    }

    MultipartBody requestBody = builder.build();
    Call<SocialCreateFeedResponse> call = mSocialClient.createFeeds( requestBody);
Code_Life
  • 5,742
  • 4
  • 29
  • 49