如何使用 Amazon S3 创建一次性下载链接? [英] How can I create a one time download link with Amazon S3?

查看:71
本文介绍了如何使用 Amazon S3 创建一次性下载链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个指向亚马逊 s3 托管文件的一次性下载链接.下载文件后,此链接将失效.

I want to create a one time download link to an amazon s3 hosted file. This link expires once the file has been downloaded.

我希望仍托管此文件,但访问者只能下载该文件一次.

I want this file to still be hosted but a visitor can only download the file once.

我需要它的场景是:我有一个文件下载网站,用户可以在该网站上为文件付费.我希望用户只能从网站(和 Amazon s3)下载文件一次,我也不希望用户能够与其他人共享直接下载链接.

The scenario I need this for is: I have a file download website where users pay for a file. I want the user to only be able to download the file once from the website (and Amazon s3), I also do not want the user to be able to share a direct download link with other people.

如果这不可能,我想知道如果可能的话,通过 IP 地址或 Cookie 限制它是否更有效?

If this isn't possible I wonder if it is more efficient to limit it by an IP address or Cookie if possible?

推荐答案

没有办法告诉 S3 只允许使用一次链接.但是您可以创建一个只能在指定时间之前使用的链接.我所做的是将请求者重定向到几分钟后过期的 S3 链接,因此他或她没有时间分享它.您可以将过期时间设置得非常短,甚至几秒钟,只要他们的浏览器有时间接收重定向响应并遵循它即可.

There is no way to tell S3 to allow a link to be used only once. But you can create a link that can only be used until a specified time. What I do is redirect the requester to an S3 link that expires in a few minutes, so he or she doesn't have time to share it. You can make that expiration time very short, even a few seconds, so long as their browser has time to receive the redirect response and follow it.

这篇关于如何使用 Amazon S3 创建一次性下载链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆