I want to build simple servlet that accepts single file via post and write it somewhere. The curl will be like:
$ curl -X POST -H "Content-Type: Application/Octet-Stream" --data-binary @thrw.pdf http://localhost:8080/MyServlet
However, my servlet request.getContentLength() returns > 0, but request.getInputStream().available() return 0. Perhaps this is trivial, but i am unable to figure out how to read the uploaded file. As getInputStream().available() returns 0, it is not possible to read the bytes via:
InputStream in = request.getInputStream();
in.read(chunk);
Basically, i want to ask. Is it possible to get the file? If it is, how to achieve that?
Update Actually the InputStream in, is now working - i don't know why, it won't work before - however, it breaks uploaded files (pdf, png, but not txt).