FileDownloader - Can We Tell When Download Is Complete?

Hi.

I have an application that generates a potentially large zip file that can be downloaded to clients using the FileDownloader component.

The zip file is created dynamically, and is stored in a ‘temporary’ directory within the servlet context (ie wherever Tomcat explodes the our vaadin app war to).

The zip file is only needed for this one download. As this can be quite a big file, I would like to delete it immediately following the download completion. Is there any way I can detect this? There is nothing obvious on the FileDownloader object…

Many thanks,
Lee.

(Vaadin 7.1.5)

For what its worth, my current workaround will be to write to a temp directory unique to the vaadin session, and delete that directory when the session is considered gone…but I would much rather delete the file immediately.

You can do it so:

FileDownloader fd = new FileDownloader(resource) {
  @Override public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException {
     File file = new File("path to your file");
    
     boolean result = super.handleConnectorRequest(request, response, path);

     if (file.exists()) {
        file.delete();
     } 

     return result;
  }
};