3

I am trying to implement a (jetty-based) servlet supporting the uploading of (large) files from a web client, where a little javascript splits some user-selected file into chunks, and sends these chunks to the server using several POSTs with appropriate Content-Range headers (the rationale of this technique is to be able to track progress, pause and resume upload).

I have come up with an HttpServlet overriding the doPost() method, which handles the Content-Range header - i.e. which writes the payload at the specified location into a file on the server.

Is there a better/recommended way to support (large) file upload in a servlet? Is there a set of classes in jetty that does just that?

Thanks in advance

Noe
  • 386
  • 1
  • 5
  • Wouldn't the built-in features of [HttpServletRequest.getParts()](http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getParts()) (part of Servlet spec 3.0+) do what you are saying? – Joakim Erdfelt Dec 02 '14 at 15:34
  • This method returns each part of a multipart HTTP message. For the GetParts() method to respond, I assume that all the parts must first have been received by the server - so the entire stream must first have been dumped in a place (RAM or disk) decided by the server, prior to give the servlet the hand back and have it do whatever it wants with the content (eg re-dump it at the "right" place). Are these assumptions of mine correct? If it is the case, this would put too much burden on the system for multi-terabyte files.. – Noe Dec 03 '14 at 10:14

0 Answers0