开发者

How to offer large audio files for download after payment

开发者 https://www.devze.com 2022-12-23 05:53 出处:网络
I want to offer audio files for download on my site, after a user has completed a PayPal transaction. The commerce side of it is already written and working - the site is built in PHP with Zend Framew

I want to offer audio files for download on my site, after a user has completed a PayPal transaction. The commerce side of it is already written and working - the site is built in PHP with Zend Framework.

So that I don't incur large charges for storage and bandwidth, I'd like to host the files on a service like Amazon S3. However, I'm not sure if this is suitable for my requirements. Once the PayPal transaction is completed, I'd like to assign the user a unique id key of some kind, send them to a location where they enter the key, and the file they have bought is offered for download. The key would then expire.

I have no problem with writing the code to generate, store and delete the key. My question is this: how can I protect/hide a file stored on Amazon S3, and then offer it for download to an authorised user with a URL which subsequently becomes invalid, whilst also transferring the file directly开发者_C百科 from Amazon, rather than it passing through my server?

Is this possible, or do I need another solution?


Amazon S3 has a "Pre-signed URL" feature which allows you to build a URL to access otherwise-protected content, with a time limit. See the Query String Request Authentication Alternative documentation.


Admittedly I know very little about Amazon S3, but if you stored the file in a database in S3 and wrote a page that would serve the file from the database given a correct key. Then all you would have to do was to publish a web-service on S3 that you could call from your website to authorize a given key, and after that just redirect your user to the page that serves the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号