How to generate Amazon S3 pre-signed URL for vanity domain using amazon sdk?

I have an s3 bucket called foo.example.com, which is all CNAMEd correct.

I am moving on to the latest AWS.net SDK.

I want to create a pre-signed url as:

http://foo.example.com/myfile.txt?s3_params_here

Pay attention to the vanity of cname.

I have:

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

The url I get is something like:

http://foo.example.com.foo.example.com/myfile.txt?AWSAccessKeyId=bar&Expires=1331069777&Signature=234KoUUvfE1nCcs2vLj9RQUhqF8%3D

This is clearly wrong.

I tried buch of various options with ServiceURL, bucketname, etc., but nothing works.

I cannot find good documentation - what is the right way to do this?

Thank.

+4
source share
2

[ ]

, , , URL-. (.. ), :

string bucketName = "foo.example.com";

// [...]

GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
    .WithBucketName(bucketName)
    .WithKey(key)
    .WithExpires(DateTime.Now.AddMinutes(32))
    .WithProtocol(Protocol.HTTP);

URL- , .. http://foo.example.com.foo.example.com/myfile.txt?[...]

, :

string url = s3Client.GetPreSignedURL(request);

// KLUDGE: remove duplicate domain name.
url = url.Replace(bucketName + "." + bucketName, bucketName);

URL (.. http://foo.example.com/myfile.txt?[...]), , .

URL-, , , , , . Query String Request Authentication Alternative, , :

StringToSign = HTTP-VERB + "\n" +
    Content-MD5 + "\n" +
    Content-Type + "\n" +
    Expires + "\n" +
    CanonicalizedAmzHeaders +
    CanonicalizedResource;    

, ; section .

, ​​AWS SDK .NET, ., , S3 , , "+" ? , , ; , , , AWS / , .

!


[dysfunctional]

SAME CNAME bucket , , , GetPreSignedUrlRequest, :

GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
    .WithKey(key)
    .WithExpires(DateTime.Now.AddMinutes(5))
    .WithProtocol(Protocol.HTTP);

, , .

0

presignedURL URL . , , :

  • , URL- , , "//", , > "/", some > https:///x/y/z/abc.png - x/y/z/abc.png > , /x/y/z/abc.png

  • , URL- a > URL url.getQuery() , , awsURL s > - - .

, .

url.getQuery url, .

https://forums.aws.amazon.com/thread.jspa?threadID=70521

0

All Articles