Skip to content
Advertisement

Sending Image files and Text from android app java HttpURLConnection multipart form-data

Hi I am trying to upload a file and a text, using multipart form-data HttpURLConnection java, sample of code below:

JavaScript

additional details: I/File:: /storage/emulated/0/DCIM/100ANDRO/DSC_0117.JPG I/Api response: 400, Bad Request

Note: I tested server from postman, and it working with no issues with Postman, the files where uploaded successful to the server from postman.

This link is another post of a sample of a web api i am using to read the request: link_here

Update: I had to modify my web api a bit as i wasn’t using properly, the code works fine now

JavaScript

and in Blob images Azure, i see that the image it is not visible, it is corrupted.

so my last issue was in write of the image, correct code below, works like a charm now 😉:

JavaScript

Advertisement

Answer

so my last issue was in write of the image, correct code below, works like a charm now ;):

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement