Multiple File Upload with Vaadin and HTML5/Flash


i’m trying to implement a multiple file upload, based on swfupload-gwt or html5 multiple file upload.
i know that in the higher abstraction layers there is no chance to get connected with such low level input forms.

the problem is that i don’t see any point of intersection where i can get as low as needed to handle the post requests by myself.

i’m thinking about something like going down to the http servlet and check the post methods by myself, so i have also the ability to get an InputStream and use the files in the higher Abstraction Level.

Do you guys have any ideas?


The people who really know this part are on vacation, but some starting points if you didn’t get that far yet:

For servlets, the key methods to look at are AbstractApplicationServlet.getRequestType(), AbstractApplicationServlet.service() and AbstractCommunicationManager.doHandleFileUpload(). The service method forwards all requests it considers file upload requests to the communication manager, whose method doHandleFileUpload() uses some parts of a modified Apache commons fileupload library (found in the com.vaadin.external.* packages).

One of the key problems is probably that the servlet does not provide a hook point for handling just the uploads in the correct place, and using your own application context or communication manager without modifications to the core classes might be a problem. The only way I see based on a quick glimpse at the sources would be to create your own application context for the session in the beginning of an overridden service() method before calling super.service(), and having that context create your custom communication manager. You do need to go outside the public APIs for this, though, so there is a risk of future versions of Vaadin breaking your modifications.

I recommend you download the full ZIP package for Vaadin, which also contains the com.vaadin.external source code in build/external/fileupload. The build/build.xml target compile-fileupload calls a target in build/external/fileupload/build.xml in case you need to test modifications to this part.

For JSR-286 portlets (Portlet 2.0), handling file upload is slightly more complicated and uses an action request, but much of the implementation is shared with the servlet side.

If you do manage to make a Vaadin add-on for this, that would be great.