限制亚马逊S3下载 [英] Limiting amazon s3 downloads

查看:80
本文介绍了限制亚马逊S3下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个iOS应用,该应用会将小视频上传到Amazon s3.然后,视频将是公开的,用户将可以共享每个视频的URL.我担心流媒体的成本(例如,如果视频要传播病毒).每GB带宽约$ 0.12,这很快就会变得昂贵.

I'm working on an iOS app which will upload small videos to amazon s3. The videos will then be public and the user will have the ability to share out a URL for each video. I'm concerned about streaming costs (if a video were to go viral, for example). At ~$0.12 per GB of bandwidth, this could quickly get expensive.

我想为每个视频实施某种下载限制,以防止出现这种情况.视频每月被下载一定次数后,就不再公开并且无法下载.

I'd like to implement some sort of download limit for each video to prevent this. Once a video has been downloaded a certain amount of times per month, it's no longer public and cannot be downloaded.

我浏览了各种文档,但没有找到实现此目的的好方法.我发现的唯一可能的解决方案是定期拉出s3存储桶的日志文件,并使用该数据来确定已下载某些视频的次数.这是我最好的选择,还是有更好的方法?

I've looked through various docs and am not finding a good way to accomplish this. The only potential solution I've found is to periodically pull down the log files for my s3 bucket, and use that data to determine how many times certain videos have been downloaded. Is this my best bet here, or is there a better way?

谢谢!

推荐答案

您可以执行此操作,但是将需要对您进行一些编码才能使其正常工作.

You can do this, but will require you to do some coding on your end to make it work.

方法1 将是启用详细的s3日志记录统计信息,然后编写代码以解析那些日志文件并在达到限制时按文件确定,然后撤消对该文件的许可以防止不再提供它.

Method 1 would be to enable detailed s3 logging stats, and then write code to parse those log files and determine by file when an limit has been reached, and then revoke permission on the file to prevent it from being served any more.

以下是有关如何启用详细的s3日志记录的信息:

Here is info on how to enable detailed s3 logging:

http://docs.aws.amazon.com/AmazonS3/最新的/UG/ManagingBucketLogging.html

相对简单,但可能有点笨拙,并且由于提供日志的固有延迟和处理日志的延迟,您确实存在超出极限的风险-大约20分钟到一个小时或更长时间一旦达到限制,但在您的应用程序没有足够的信息来实现它之前,时间就可以买了.

Relatively simple, but perhaps a bit inelegant and you do run the risk of going over your limit because of the inherent delay in logs being made available and the delay in processing your logs - so maybe 20 minutes to an hour or more of time might go buy once a limit has been reached, but before your application has enough information to realize it.

方法2 ,它的imo更优雅,它会在您的ios应用和s3之间放置一个ec2实例(一个或多个实例)-ios应用向ec2实例发出请求,它会真正查找时统计信息(它已经积累了自己的声音,可能存储在dynamodb或rds中),然后将s3 url返回到适当的视频,或者将超限错误返回给应用程序.使用此方法,无需撤销s3特权,因为ec2实例充当流量警察,并且可以实时完成对特定文件的启用/禁用访问-您还可以轻松地添加实时报告/通知容量,使用此方法可以让您知道文件或文件何时传播病毒,如果有帮助的话.

Method 2, which imo is a bit more elegant would put an ec2 instance (or instances) in between your ios app and s3 - ios app makes a request to ec2 instance, it lookups up real-time statistics (that it has been accumulating itself, perhaps into dynamodb or rds) and then either returns an s3 url to the appropriate video or returns an over-limit error to the app. Using this method there is no need to revoke s3 privileges, because the ec2 instance acts as a traffic cop and the enabling/disabling access to a particular file can be done in real-time - you also could easily add real-time reporting/notification capacity using this method to let you know when a file or file is going viral if that would be useful.

这篇关于限制亚马逊S3下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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