2
我希望通過@PartMap或@Part(「avatars_attributes []」)等方式發送陣列圖像到服務器。但沒有結果。也許你可以幫助我?Retrofit 2發送圖像陣列到服務器
對於@PartMap我使用HashMap中的一些內容:
for(int i = 0; i < images.size(); i++){
Bitmap btm = images.get(i);
ByteArrayOutputStream out = new ByteArrayOutputStream();
btm.compress(Bitmap.CompressFormat.JPEG, 50, out);
byte[] profilePictureByte = out.toByteArray();
final RequestBody imageBody = RequestBody.create(MediaType.parse("image/*"), profilePictureByte);
map.put("avatars_attributes[]\"; filename=\"avatars_attributes" + i + ".png\"",imageBody);
和
@Multipart
@POST(ApiRetrofitUrls.TRANSPORTS_URL)
Call<TransportEntity> addTransport(@PartMap() Map<String, RequestBody> map);
但服務器接收只空數組avatars_attributes [];
在另一方式中,我使用RequestBody或RequestBody []的ArrayList中,
但結果是一些。
謝謝。
可以共享服務器請求合同 –
其崗位要求和參數 「avatars_attributes []」 的圖像陣列 –