使用ASP .Net创建到S3或Cloudfront托管内容的过期链接

bra*_*man 2 vb.net asp.net web-services amazon-s3 amazon-web-services

有没有人使用ASP .Net创建一个过期的签名URL?我正在探索在我的项目中使用LitS3ThreeSharp,并且在这两个项目中都没有看到任何具体方法.谢谢.

Fra*_*len 5

以下是使用AWS开发工具包和MVC 3的工作原理(基于上面的答案以及我在http://www.ec2studio.com/articles/s3.html找到的内容):

public ActionResult GetS3Object(string bucket, string key)
{
    string accessKeyID = ConfigurationManager.AppSettings["AWSAccessKey"];
    string secretAccessKeyID = ConfigurationManager.AppSettings["AWSSecretKey"];
    using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKeyID, secretAccessKeyID))
        {
        GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
            .WithBucketName(bucket)
            .WithKey(key)
            .WithExpires(DateTime.Now.Add(new TimeSpan(7, 0, 0, 0)));
        return Redirect(client.GetPreSignedURL(request));
        }
}
Run Code Online (Sandbox Code Playgroud)