Upload file from MultipartEntityBuilder, added headers in file

410 Views Asked by At

I upload a JSON file using MultipartEntityBuilder. on another side when I read the file some headers are added on both top and bottom of the file. I tried many things to remove headers from a file but no success.

here is the code how I write multipart request

HttpPost request = new HttpPost("/getFile");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", new File("abc.json"), ContentType.APPLICATION_JSON, "abc.json");  
HttpEntity entity = builder.build();
request.setEntity(entity);

uploaded file

--ZD1OkvwbsjLAuhqTLx2I6HzWkZcH9oHoBbTN Content-Disposition: form-data; name="upfile"; filename="abc.json" Content-Type: application/octet-stream

{ "version": "1.2", }

--ZD1OkvwbsjLAuhqTLx2I6HzWkZcH9oHoBbTN Content-Disposition: form-data; name="text"

This is a multipart post --ZD1OkvwbsjLAuhqTLx2I6HzWkZcH9oHoBbTN--

how can I send only JSON part not these top and bottom headers

0

There are 0 best solutions below