简体   繁体   English

链接到不带URL的S3文件-Rails-AWS-SDK

[英]Linking to S3 file without URL - Rails - aws-sdk

I have an S3 account, on which are stored videos which I need to play using an HTML5 Video element inside a rails application. 我有一个S3帐户,上面存储了我需要使用Rails应用程序中的HTML5 Video元素播放的视频。

Is it possible for me to be able to load the videos into the player without making the video public and directly linking to it? 我是否可以在不公开视频并直接链接到播放器的情况下将视频加载到播放器中?

I have the gem aws-sdk and I read through the documentation and didn't find any information about this. 我有宝石aws-sdk,并且阅读了文档,但没有找到任何有关此的信息。

Excuse me? 劳驾? How is it unclear what I'm asking? 不清楚我要问什么? It's not really possible to make it clearer so I guess I'll basically restate what I already said. 确实不可能使它更清晰,所以我想我基本上会重述我已经说过的话。

I need to be able to this: 我需要能够做到这一点:

<video src="<url of file on S3>"> without making the file public in S3 so anybody can download it. <video src="<url of file on S3>">而无需在S3中将文件公开,因此任何人都可以下载它。

Look ar presigned URLs. 查找预签名的URL。 Use the Presigner in the ruby sdk on the server to generate a presigned URL (for get method) for the key and insert that into the html. 使用Presigner在Ruby SDK中的服务器上生成的密钥presigned的URL(GET方法),并插入到HTML。

To access private content in S3 from your rails application, there are multiple approaches available 要从Rails应用程序访问S3中的私有内容,可以使用多种方法

  • Create a Sign URL using Ruby AWS SDK from your Rails Backend and return the URL to the browser so that your HTML5 player can access them 使用Rails后端中的Ruby AWS SDK创建Sign URL,并将URL返回到浏览器,以便HTML5播放器可以访问它们
  • Using AWS STS and AWS Ruby SDK at Rails Backend, generate a temporarily access token (Which has grants to s3 bucket) and return it to the browser, where browser can use AWS JS SDK + Token to request the file 在Rails后端上使用AWS STSAWS Ruby SDK生成一个临时访问令牌(已向s3存储桶授予了该令牌),并将其返回到浏览器,浏览器可以在其中使用AWS JS SDK +令牌来请求文件

For better performance use AWS Cloufront RTMP distributions for the Videos which serves the files from S3 with Signed URLs and Origin Access Identity limiting public access 为了获得更好的性能,请对视频使用AWS Cloufront RTMP分发,该分发通过签名URLOrigin Access Identity限制公共访问来提供S3中的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM