Pregunta

Server receives some data from the client in the post request. to send that data, I use smth like this:

HttpPost post = new HttpPost(_config.url);
MultipartEntity entity = new MultipartEntity();
for (Entry<String, ContentBody> e : params.entrySet()) {
    entity.addPart(e.getKey(), e.getValue());
}
post.setEntity(entity);

When server accept request, data stored in request body. If I read it as char array and convert it ot string, I can see this info:

--ltiKmQX6YRvytGyyKS_F3Zz__tVbvbQktQV
Content-Disposition: form-data; name="file"; filename="art21.jpg.0"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

ÿØÿàJFIFHHÿÛC
2!!22222222222222222222222222222222222222222222222222ÿOX"ÿÄ

However as you can see request contains several parameters: filename and file. How can I get those parameters from the request body ?

¿Fue útil?

Solución

finally found solution:

To get data binary data from post body i use ServletFileUpload from apache:

List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top