1

I've been trying to find out a standard compliant way of handling multipart/mixed contents as a stream using JAX-RS. By default (if I've not mistaken) multipart fragments are stored in memory or as temporary files before the container passes the request to the service.

The reason why I prefer direct streaming over streaming from temporary files is that each part of the multipart/mixed request contains a file, that must be persisted reliable storage (= clustered database) in a single transaction. Because there should be no size limit for the files that are transmitted over the system, and both the client and the server are located in local network, storing gigabytes of data in temporary files (on SAN) will cause a significant performance hit.

Is there a way to stream parts directly to the database using JAX-RS? If not should I implement the service as a servlet or split the transaction to multiple requests and use JAX-RS? Implementing the service as a servlet would require a streaming multipart/mixed compliant parser while splitting the transaction wouldn't be a trivial task either.

Sami Korhonen
  • 1,254
  • 8
  • 17
  • Possible duplicate with [this question](http://stackoverflow.com/questions/6301973/multipart-file-upload-on-google-appengine-using-jersey-1-7/6304378#6304378). – yves amsellem Oct 09 '12 at 16:20
  • Unfortunately it's not a duplicate. Caching messages, that may well be over gigabytes in size, in memory is not a solution that I'm interested in. I think I'll start experimenting with mime4j + servlet. – Sami Korhonen Oct 16 '12 at 19:34

0 Answers0