I am trying to upload image by POST multipart request which should have structure like this :
-----------------------------219391268715340 Content-Disposition: form-data; name="photos[]"; filename="DSCF0157-Laptop.JPG" Content-Type: image/jpeg
(byte-data)
My code :
MediaType mediaType = MediaType.parse("image/jpeg"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArray = stream.toByteArray(); RequestBody file=RequestBody.create(mediaType, byteArray); map.put("form-data; name=\"photos[]\"; filename=\""+filename+".jpg",file); I use map because of @PartMap annotation - I want to upload multiple files. My server returns http code 200 - but no files are uploaded. Api call has been tested - it works correctly if used by our web application. Any idea what I am doing wrong