我有一个名为 foo.example.com 的 s3 存储桶,它的所有 CNAME 都正确。
我正在切换到最新的 AWS .net SDK。
我希望生成预签名的 url,如:
http://foo.example.com/myfile.txt?s3_params_here
注意那里的虚荣cname。
我有:
string bucketName = "foo.example.com";
AmazonS3Client s3Client = new AmazonS3Client("bar", "xxx",
new AmazonS3Config
{
ServiceURL = bucketName,
CommunicationProtocol = Protocol.HTTP
});
string key = "myfile.txt";
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
.WithBucketName(bucketName)
.WithKey(key)
.WithExpires(DateTime.Now.AddMinutes(5))
.WithProtocol(Protocol.HTTP);
string url = s3Client.GetPreSignedURL(request);
Run Code Online (Sandbox Code Playgroud)
我得到的网址是这样的:
这显然是错误的。
我已经尝试了许多不同的 ServiceURL、bucketname 等变体,但似乎没有任何效果。
我找不到任何好的文档 - 这样做的正确方法是什么?
谢谢。