How to know when a download is complete

Hi, I am creating an online store. In this case, people on the Internet should buy files with the zip extension. They pay with their credit cards or other methods, get a key, and download the product. How can I know when they finish downloading the product? Thanks to

+2


source to share


3 answers


Unfortunately, there is no really good way to do this, as some clients may not download the file right away (e.g. Downloadmanagers split the download into multiple party batch downloads).

Parameters:

  • If it is very important to you that it can be downloaded only once: you may simply not support renewal. You can then log if the file is completely downloaded (as soon as the last byte has been sent). This can work if the download is small.
  • Otherwise, you can offer some data finesse (we usually allow clients to download 5 times the actual download) and log each download.


You shouldn't just count the downloaded bytes (because the download might be broken). And it is NOT easy to determine if all partitions have been downloaded once (also because the download may be broken)

Just to clarify: this all means you have to write your own upload handler (file server).

+2


source


you can use a custom file server that runs on http or ftp and send a notification to it after the client has received the last piece of the file.



all other options are problematic; the client can download the file using the download manager, so you can't even register for any browser event, if any.

0


source


A custom server app is really the solution for this, or maybe some scenarios.

A normal HTTP server does not notify when the connection ends, but perhaps if you generate output in a cgi / php / asp / * script, you read the file in cgi / php / asp / * scripting language and send it out. when you get to the end of the file you will issue a notification and then terminate the script.

When you do this, it will only detect fully downloaded files, and if the connection is interrupted halfway it will not mean the file has downloaded.

a 'cgi-script' can be a compiled c-program (or any other langauge for that matter). Compiled code anyway. A compiled program will give better performance than an interpreted script solution.

0


source







All Articles