Create AWS S3 Pre-Announcement URL with my own domain / subdomain

I am using the AWS SDK for .NET and I am currently generating assigned urls for my S3 bucket.

The urls I am currently getting are like https://{bucketname}.s3.amazonaws.com/{FileAndQueryParameters}

What I was looking for was something like https://{MyDomainName}/{FileAndQueryParameters}

I already tried to replace the first url with my own CNAME pointing to {bucketname}.s3.amazonaws.com

, but I get the obvious

<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>

      

Any ideas how to do this?


By the way, this is the code I'm using right now:

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

      

+3


source to share





All Articles