New Zenner
- Join Date:
- Jan 2011
- Location:
- Leicestershire, UK
- Posts:
- 5
- Plugin Contributions:
- 0
Remote downloads - for Amazon S3 or other
**DOWNLOAD LINK:
http://www.zen-cart.com/downloads.php?do=file&id=1352
**
Hi,
I've recently started looking after a Zen Cart store for a small publishing company, and they wanted the ability to sell video downloads of their DVDs, and sell watermarked PDFs. Using Amazon S3 looked like a reasonable way to begin with for the rather large videos, but I couldn't find any way of doing the right redirect in Zen Cart. Also, it could handle plain PDFs, but not process them to add a watermark with the customer's name, etc.
I've therefore written a small patch (to 1.3.9h) that allows a download to run a script rather than serve the file to the customer. This makes it really easy to do both the above. The patch is about 30 changed lines, and 50 new, plus a 50-line "plug-and-play" example of how to do downloads from Amazon S3.
It works by including scripts from a "download script" directory at download time that can do a web redirect. To tell Zen Cart to download via a script rather than a static file, you put for example "script:amazons3.php" in the filename box.
At download time it includes the script, which can then do an HTTP redirect to wherever necessary. The S3 one encodes up the requested filename with an expiry date a few seconds into the future, so the download link can't be shared with other people, and then redirects to the Amazon URL. For the PDF watermarks I use a different script that encodes the customer name from the database on to the URL, with a crypto signature, and then redirects to another server to process the PDF.
Once a script is in place it can be given different options to process from the admin interface. For example, one download attribute might have "script:amazons3.php:episode1.m4v" and another might have "script:amazons3.php:episode2.m4v".
The only problem I've got now is trying to work out where to submit the patch (sorry, I get very confused with web forums!) I've put it here if anyone would like to review: dl.newtoncomputing.co.uk/downloadscripts.patch. It applies cleanly to the latest 1.3.9h zip: cd into the zen cart diretory and do 'patch -p1 < ../downloadscripts.patch' to apply.
If I should send it somewhere else or submit this some other way then please let me know. :-) Hope this helps someone!
Cheers,
Matthew