0

I'm working on a online document management system where users can download multiple documents as a single ZIP file. These files can get to large to handle completly in memory so in that case we use a temp file. That temp file is then send to the client using Http11NioProtocol with org.apache.tomcat.sendfile set to the temp file. The problem is after tranferring the file to the clients browser the server is stuck with a temp file.

Ofc. it's possible to use deleteAfterExit or some sort of tempFileManager but what I'm looking for is a way to register a handler function when the file is completly transferred or have some sort of callback function that can be used to clean up the temp files?

SvK
  • 11
  • 2

1 Answers1

0

If you are running on linux you can safely delete the files even if the transfer hasn't completed. You can't delete the file straight away because the tomcat sendfile code has to be able to open the file but you can probably safely delete the file after a minute.

benmmurphy
  • 2,503
  • 1
  • 20
  • 30
  • Doing this wont be a lot different from registring the file with a tempfileManager with the assignment of deleting the file 1 minute after setting the download. I would much rather do some action as soon as the download is done and not hope the file is deletable after x minutes – SvK Apr 04 '12 at 07:36