Finding out is user fully completed download or not
I have an webapp which dynamically generates a file and stores it on the server. When a user comes along, this file is served, after which it gets deleted. Each user gets their own generated file after which it becomes useless.
Is there a way to know if the user managed to download the file fully, so that it may be deleted and not clogging up my server with outdated files?
At the moment the problem i开发者_开发知识库s a user is clicking "Download file" then it being cancelled or failed, so they try again but its been deleted.
There's no way to tell for certain whether the file was downloaded completely - even if you counted the bytes that the browser downloaded, what if their browser downloaded every byte of it but then crashed, for instance?
A common solution to this problem is to leave the file there for a predetermined period, then delete it. You tell the user "Your download will be available for the next 48 hours."
(The exact example above happened to me with Amazon's MP3 Store. I had to contact customer services for them to re-enable the download, which to their credit they did very quickly, but getting Customer Services involved for something like that is expensive.)
Have the user click a "Continue" button after they download the file, and delete the file at that point.
精彩评论