C# 无法使用.NET的AWS SDK获取预先签名的对象URL
我目前正在使用S3,需要提取一个S3资源,该资源有一个流超时,以便客户端在特定时间后无法使用URLC# 无法使用.NET的AWS SDK获取预先签名的对象URL,c#,amazon-s3,C#,Amazon S3,我目前正在使用S3,需要提取一个S3资源,该资源有一个流超时,以便客户端在特定时间后无法使用URL 我已经使用了文档中提供的“使用AWS SDK for.NET预签名对象URL”的一些代码 该代码将提供一个临时URL,任何人都可以使用该URL下载S3资源……但必须在特定的时间限制内 我还使用了AmazonS3Explorer for Visual Studio,但它不支持为嵌入AWSKMS密钥的资源生成URL 还尝试删除S3文件夹的KMS密钥,但这会引发错误 如果有删除KMS密钥的可能链接,您也
//Code Start
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using System;
namespace URLDownload
{
public class Class1
{
private const string bucketName = "some-value";
private const string objectKey = "some-value";
// Specify your bucket region (an example region is shown).
private static readonly RegionEndpoint bucketRegion = RegionEndpoint.USEast1;
private static IAmazonS3 s3Client;
public static void Main()
{
s3Client = new AmazonS3Client(bucketRegion);
string urlString = GeneratePreSignedURL();
Console.WriteLine(urlString);
Console.Read();
}
static string GeneratePreSignedURL()
{
string urlString = "";
try
{
//ServerSideEncryptionMethod ssem = new ServerSideEncryptionMethod("AWSKMS");
GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
{
BucketName = bucketName,
Key = objectKey,
Expires = DateTime.Now.AddMinutes(5),
Verb = 0,
ServerSideEncryptionKeyManagementServiceKeyId = "some-value",
ServerSideEncryptionMethod = ServerSideEncryptionMethod.AWSKMS
};
urlString = s3Client.GetPreSignedURL(request1);
}
catch (AmazonS3Exception e)
{
Console.WriteLine("Error encountered on server. Message:'{0}' when writing an object", e.Message);
}
catch (Exception e)
{
Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
}
return urlString;
}
}
}
signaturedesnotmatch
我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
AKIA347A6YXQ3M4JQ7A
这是我在尝试访问生成的URL时遇到的错误,这可能是因为AWSKMS身份验证存在一些问题