чт, 26 мар. 2020 г. в 18:03, Christopher Schultz <ch...@christopherschultz.net>:
> All,
> I'm developing my first multipart handler since .. I dunno, maybe
> 2005? This is the first time I'll be using the Servlet 3.0 multipart
> handling, of course through Tomcat. Some of these questions may have
> answers which are "implementation-specific", so in this case, I would
> like to know how things will behave in Tomcat specifically. Notes of
> where the spec leaves things up to the implementation will be appreciate
> d.
> I'd like to submit a form which has not only a large-ish file part,
> but also some regular fields like <input type="text">. My
> understanding is that I'll have to read those data by calling
> Part.getInputStream(), wrapping the InputStream in an
> InputStreamReader using the right charset, etc.

I think that those are available via the standard
request.getParameter(name) API.

> [...]
> Can I rely on the client to send the fields in any particular order?
> I'm not expecting to store the file on the server myself; I'd like to
> process it in a "streaming" fashion and not touch the disk if
> possible. I know that the server may store the file on the disk if it
> decides to. I'm not terribly worried about that. I just don't want to
> have to write the file to the disk TWICE, and I need information from
> those other parameters in order to configure the stream-processing.

Michael already answered this. There is a configurable threshold.
Anything over it will be written to disk as a temporary file.

The JavaDoc for Part.write() says that it can be implemented as moving
the file. "This method is not guaranteed to succeed if called more
than once"

> When iterating over the Collection<Part> returned from
> HttpServletRequest.getParts(), am I required to process each part in
> order immediately? Or can I store a reference to a Part for later?
> This kind of goes along with the previous question.

You can store the reference, but your "for later" should be no longer
than until the request processing ends.

> When I'm done with a part, must I explicitly call Part.delete()?

Tomcat deletes the files automatically (I implemented this feature in
Tomcat 7.0.30 - see changelog). In my own web applications I delete
the files explicitly (calling part.delete() in a cycle).

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to