[英]How do I access a file in Amazon S3 private bucket through simple URL?
I have video file in S3 private bucket. 我在S3专用存储桶中有视频文件。 And I want my application to open it in a video player by using a URL.
我希望我的应用程序通过使用URL在视频播放器中打开它。
I think I saw a url in this format: http://s3.amazonAWS.com/bucket/filename?signedstring
我想我看到了以下格式的网址:
http://s3.amazonAWS.com/bucket/filename?signedstring
: http://s3.amazonAWS.com/bucket/filename?signedstring
where signedstring
is a query with params AWSAccessKeyId, Expires, Signature
其中
signedstring
是具有参数AWSAccessKeyId, Expires, Signature
的查询
I have access key ID. 我有访问密钥ID。 But when I tried to read up on how to sign it - the things make little sense to me..
但是,当我尝试阅读有关如何签名的内容时,这些事情对我来说毫无意义。
Is this approach the simplest one ? 这是最简单的方法吗?
I dont really need everything. 我真的不需要一切。 I just need to be able to construct a URL and open video file.
我只需要能够构造一个URL并打开视频文件。
Is there a simple C# code to sign the query ? 有没有简单的C#代码来签署查询?
You can use the AWS SDK for .NET ( http://aws.amazon.com/sdkfornet/ ) to create pre-signed URLs for your S3 Objects. 您可以使用适用于.NET的AWS开发工具包( http://aws.amazon.com/sdkfornet/ )为S3对象创建预签名的URL。 Here's an example that will create a pre-signed url that is valid for 15 minutes:
以下示例将创建一个有效期为15分钟的预签名网址:
var s3Client = new AmazonS3Client(awsKeyId, awsSecretKey);
var url = s3Client.GetPreSignedUrl( new GetPreSignedUrlRequest {
BucketName = bucket,
Key = objectKey,
Expires = DateTime.UtcNow.AddMinutes(15)
});
There are additional examples in the documentation for GetPreSignedUrl()
. 文档中
GetPreSignedUrl()
其他示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.