Results 1 to 2 of 2

Thread: Large multipart uploads (with an applet) and exceptions.

  1. #1
    Join Date
    Aug 2005
    Posts
    28

    Default Large multipart uploads (with an applet) and exceptions.

    I've just recently been working to get a form together which is capable of submitting a multi-file post by way of a java applet. So far, things are working well and I take my hat off to Commons FileUpload in particular; I was worried early on that streaming to disk wasn't possible.

    The problem I am noticing is to do with exceptions. It's not that I can't handle them, its when they occur. In testing, I've sent a few posts that were ~200MB and also exceeded maxUploadSize. What I expected was that a SizeLimitExceededException would be thrown and the post would stop immediately. However, what I am noticing is that the MultipartResolver has noticed the limit was exceeded (as I can see it's complaint in the log), but an exception wasn't thrown until the post was completed some minutes later.

    What makes this a bit more serious is that the resolver appears to be ignoring the post (since the limit was exceeded) and, since it is now being treated as a regular post, the data isn't being cached to disk as it arrives. So the 200MB post is consuming physical memory, completing, and then the exception is being thrown.

    Now, I expect this is because I am manually parsing the post during onBindAndValidate(), which is too late in the flow of execution for a more pre-emptive exception to occur. Is it possible to parse a request before it has been completed? My guess is the answer is yes, at least since the MultipartResolver is doing something similar as it caches the arriving data to disk.

    I guess I thought, since the resolver was caching the files automatically, it would be capable of throwing an exception and interrupting the post.

    My other thought is that I should be creating a custom databinder.

    Would anyone have advice on this matter? If I rolled my form back to a simple file submit and tried this with one huge file, would I see an exception thrown immediately?

  2. #2
    Join Date
    Aug 2005
    Posts
    28

    Default Well bugger...

    Well I slept on it and judging by the lack of responses, this perhaps wasn't a mystery to anyone else. After browsing the cvs of the pertinent classes, it would seem that an exception is immediately thrown. From what I know of the multipart format, this is what I originally expected since the size of the post is transmitted at the beginning. On rolling back the view to a basic html post, it would seem the applet is at fault. Time to speak to its maintainer.

    [ed] This does still leave me with concerns about handling situations where a Post is sent to my server that is well beyond the size limits that I have set. Someone could use a badly behaving Posting agent to malicously send a huge file to consume resources. Is there a means of making the server "kick harder" when such a situation occurs?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •