Downloading files....

Hey,
I am recently creating a part of the Web Application that allows only the users of the Web Application to download files and no one else… I have used FileResource class for doing so and it works…

But my problems now are :

(1) File Size is not sent to the Web Browser or the client’s download manager.
Modern download managers shows file size and progress while downloading the files. I tried to use

fileresource.getStream().setParameter("Content-Length",String.valueOf(filetodownload.length())); but in vain… So is there any other way of sending the file size or is anything wrong above in my code ???

(2) Download resume is not possible.
Using FileResource sends the entire file. My files are very large. Downloading them again from beginning due to any possible reasons like network error is not acceptable. So is there any way to support resume facility ???

(3) Multi-Threading download is not possible.
Most of the modern download managers/accelerators are multi-threaded, which is not possible using FileResource ( atleast i am not able to do it ). So is there any way to support multi-threading download ???

Thanks,
Meet Parikh

If you are serving very big files like this, I would recommend bypassing Vaadin for the files - use an ExternalResource for them and serve them from elsewhere. This is also better for performance, and allows scaling up serving the files.

If it is ok that the files can be downloaded by anyone with a URL, configure e.g. an Apache server to serve these directly and forward other requests to the Vaadin servlet. It should be possible to include e.g. an authentication based hash in the URL if necessary, and handle it on the Apache side.

If you need more control over who can access which file at what time, you could also use a separate servlet for the files, sharing authentication information vie whichever mechanism is appropriate. If necessary, you could also try to hook somehow into AbstractApplicationServlet.service() processing, but extending the class in this way might be somewhat tricky.