5

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

skaffman
  • 398,947
  • 96
  • 818
  • 769
user12384512
  • 3,362
  • 10
  • 61
  • 97

2 Answers2

1

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.

Pawel Zieminski
  • 439
  • 3
  • 8
1

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

paullth
  • 1,731
  • 2
  • 15
  • 19