我正在使用适用于 .NET 的 AWS 开发工具包,目前正在为我的 S3 存储桶生成预签名 URL。
我目前得到的网址就像https://{bucketname}.s3.amazonaws.com/{FileAndQueryParameters}
我正在寻找的是类似的东西https://{MyDomainName}/{FileAndQueryParameters}
我已经尝试用我自己的 CNAME 指向替换第一个 url,{bucketname}.s3.amazonaws.com
但我得到了一个明显的
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
任何想法如何做到这一点?
顺便说一句,这是我现在使用的代码:
(...)
AmazonS3 client = AWSClientFactory.CreateAmazonS3Client(AccessKey, SecretKey);
string S3_KEY = Key;
string BUCKET_NAME = Bucket;
string FOLDER = SubFolder;
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
request.WithBucketName(BUCKET_NAME);
request.WithKey(FOLDER + "/" + S3_KEY);
if (ssUseHTTPS)
{
request.WithProtocol(Protocol.HTTPS);
}
else
{
request.WithProtocol(Protocol.HTTP);
}
if (DownloadFileName != string.Empty)
{
ResponseHeaderOverrides responseHeaders = new ResponseHeaderOverrides();
responseHeaders.CacheControl = "No-cache";
responseHeaders.ContentDisposition = "attachment; filename=" + DownloadFileName.Replace(";", "").Replace(",", "");
request.ResponseHeaderOverrides = responseHeaders;
}
request.WithExpires(DateTime.Now.AddSeconds(SecondsValidFor));
Url = client.GetPreSignedURL(request);
return Url;