简体   繁体   中英

How do I access a file in Amazon S3 private bucket through simple URL?

I have video file in S3 private bucket. And I want my application to open it in a video player by using a URL.

I think I saw a url in this format: http://s3.amazonAWS.com/bucket/filename?signedstring

where signedstring is a query with params AWSAccessKeyId, Expires, Signature

I have access key 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.

Is there a simple C# code to sign the query ?

You can use the AWS SDK for .NET ( http://aws.amazon.com/sdkfornet/ ) to create pre-signed URLs for your S3 Objects. Here's an example that will create a pre-signed url that is valid for 15 minutes:

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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