user12384512
user12384512

Reputation: 3401

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

Upvotes: 5

Views: 1731

Answers (2)

Pawel Zieminski
Pawel Zieminski

Reputation: 534

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.

Upvotes: 1

paullth
paullth

Reputation: 1751

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

Upvotes: 1

Related Questions