views:

374

answers:

3

Hi I'm creating online shop. In this shope people online must be buy files with zip extension. They pay with their credit cards or other methods get key and download product. How can I know when they finish product download? Thanks

A: 

you can use custom file server that works on either http or ftp and have it send a notification once the client received the last file fragment.

all other options are problematic; the client might download the file using a download manager,so you cannot even register for any browser event, if there was any.

geva30
Obviously your answer requires that the custom fileserver does not support resuming though.
Foxfire
+2  A: 

Unfortunatelly there is no really good way to do this as some clients might not download the file at once (e.g. Downloadmanagers split the download into several parralel part downloads).

Options are:

  • If it is very important to you that it can only be downloaded once: You could simply not support resuming. Then you can log if the file has entirely been downloaded (as soon as the last byte has been sent). This might work well if the download is small.
  • Otherwise you could offer some grace data (we usually allow to download clients to download 5 times the size of the real download) and log every download attempt.

You should NOT just count the bytes downloaded (because the download might be disrupted). And NOT just determine if all sections have been downloaded once (also because the download might be disrupted)

Just to clarify: All this means that you have to write your own download handler (fileserver).

Foxfire
A: 

A custom server application seems indeed a solution for this, or possibly some kind of scripting.

A normal http server does not notify the end of a connection, but possibly, if you generate the output in a cgi/php/asp/* script, you read the file in cgi/php/asp/* scripting language and send it to the output. when you reach the end of the file, you do the notification, and then end the script.

When you do it that way, it will only detect fully downloaded files, and if the connection gets interrupted half-way, it would not mark the file as downloaded.

a 'cgi-script' can be a compiled c program, (or any other langauge for that matter). Compiled code anyways. A compiled program would give better performance then a interpreted script solution.

andremo