Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet 3.0 streaming api for file upload

New Servlet 3.0 API provide us with convenient way to parse multi-part form data. But it stores content of uploaded files in file system or in memory

Is there streaming API for Servlet 3.0 ?

Something like Commons FileUpload. I have to write content directly from InputStream and write to another OutputStream adn I don't want to store temporary file content in disc or memory

like image 403
user12384512 Avatar asked Nov 06 '22 01:11

user12384512


2 Answers

I used this once for something similar, though not with servlets. It doesn't fill up your memory with data. Hope it helps: http://code.google.com/p/io-tools/wiki/Tutorial_EasyStream

like image 60
paullth Avatar answered Nov 12 '22 19:11

paullth


Looking at the Servlet 3.0 spec it may not be possible to have a streaming implementation

For parts with form-data as the Content-Disposition, but without a filename, the string value of the part will also be available via the getParameter /getParameterValues methods on HttpServletRequest, using the name of the part.

So the request must be parsed up front so that all the non-file parts can be exposed as HttpServletRequest parameters.

You have to use third party libraries if you need streaming.

like image 26
Pawel Zieminski Avatar answered Nov 12 '22 18:11

Pawel Zieminski