How can I know if the client has finished downloading a file

1k Views Asked by At

In my web application clients can download files from the server. My code looks a bit like this:

public void downloadFile(HttpServletResponse response, String fileName){
       File fileToDownload = getFileWithName(fileName);
       updateContentTypeAndLength(response);
       OutputStream out = response.getOutputStream();
       FileUtils.copyFile(fileToDownload, out);
}

The thing is I need to know when the client has finished downloading the file, is there a way for me to know that? Thanks.

1

There are 1 best solutions below

0
On

if the method finished ,and don't have any error,you should know the client have finished the downloading file. or you can return a status to client.