Roger, In my project, we implemented a FileManager for storing, retrieving and cleaning up files. On upload, the filemanager creates a temp file on disk and stores the file-URL in a map correlated with the session id. We also implemented a SessionListener which calls FileManager.deleteFiles() with the session-id as a parameter whenever a session is invalidated. Deleting file after finish of streaming might not be a good idea, since it is very common to download the same file multiple times.
- Rahul From: RogerV <roger.var...@googlemail.com> To: user@struts.apache.org Date: 19-11-2010 15:14 Subject: File Download with multiple files. Design question Hi I have a requirement to present the user with a list of files stored on the server, and then download the files selected to the user. If the user selects a single file - no problem. However if the user selects multiple files, then, unless anyone knows different, all the files have to be sent in the single input stream read by the stream result. Therefore I create a temporary file with File.createTempFile() and use the ZipOutputStream to zip the files and then return an input stream over the temp file. This works suprisingly well. However, the problem I've now got is, how to get rid of the temp files I am creating on the server? file.deleteOnExit() is no use because the server VM will (in theory) never shutdown. Once the download is complete Struts automatically re-displays the original selection screen and provided the user uses the applicatoin supplied navigation to exit then I can delete the temp file, but if they simply close the browser or use the browser back button to navigate away I'm still left with the temp files sitting around. Creating the zipfile in memory is not an option as some of these can potentially be huge if the user goes mad and selects everything in sight. Is there someway of detecting/intercepting the fact that the Stream result has completed before Struts gets on with deciding what .jsp to display next so that I can safely clean up? Any other suggested approaches would be welome. Regards -- View this message in context: http://old.nabble.com/File-Download-with-multiple-files.-Design-question-tp30256036p30256036.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you