简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM