Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSignedUrl() - Custom domain name? #891

Closed
aichholzer opened this issue Jan 30, 2016 · 4 comments
Closed

getSignedUrl() - Custom domain name? #891

aichholzer opened this issue Jan 30, 2016 · 4 comments
Labels
guidance Question that needs advice or information.

Comments

@aichholzer
Copy link

Question

Consider this request, for example:

params = {
  Bucket: 'myBucket,
  Key: 'image.jpg',
  ContentType: 'image/jpeg',
  Expires: 30
};

S3.getSignedUrl('putObject', params, function (error, url) {
  console.log(url);
});

which outputs: https://myBucket.s3.eu-central-1.amazonaws.com/image.jpg?...

I have created a CNAME; media.domain.com which points to myBucket.s3.eu-central-1.amazonaws.com

The idea here is to be able to provide a customDomain parameter where media.domain.com would be its value. This in order to have getSignedUrl() output https://media.domain.com/image.jpg?...

Just replacing the domain after getSignedUrl() does not work since the actual AWS S3 domain is also used for the signature.

In short; I would like to be able to specify a custom domain for putting objects to my S3 bucket.

Any ideas?

@LiuJoyceC LiuJoyceC self-assigned this Feb 1, 2016
@LiuJoyceC
Copy link
Contributor

Hi @aichholzer
Thanks for your question.
You can set your bucket endpoint when you create your instance of S3: var S3 = new AWS.S3({endpoint: 'media.domain.com', s3BucketEndpoint: true}); Then the url returned from getSignedUrl will be set to the specified endpoint. For a more detailed description of these params, please see the Constructor Details section of the API Docs: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

Let me know if you have any further questions.

@aichholzer
Copy link
Author

Hey @LiuJoyceC
Thank you for your reply.
It worked, however, I had to do a little more research since the region my bucket is in only supports v4 signatures and signatureVersion must be properly set in the configuration.

http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

@nalbion
Copy link

nalbion commented Oct 11, 2017

@LiuJoyceC #1753 is related, but has extra complexity introduced by a CloudFront path pattern

@srchase srchase added the guidance Question that needs advice or information. label Dec 6, 2018
@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

4 participants