Skip to content
Advertisement

Format of S3 pre-signed URLs

I’m trying to create an S3 pre-signed URL in my JavaScript code using:

var params = {Bucket: 'myBucketName', Key: 'key', Expires: 60};
var url = s3.getSignedUrl('getObject', params);
console.log('The URL is ', url);

After executing, my console log shows:

The URL is https://myBucketName.s3.amazonaws.com/myAudioFile.mp3

but I think it should be showing:

The URL is https://s3.amazonaws.com/myBucketName/myAudioFile.mp3

Why would it place the S3 bucket name before “s3.amazonaws.com” in the URL?

In the past it was working fine using this method. Has the AWS SDK changed?

Advertisement

Answer

That’s the format of signedURL for AWS s3 bucket. When AWS form a signed user for getObject or putObject this format remain same.

Format for AWS signed url is:

  1. https://
  2. bucketName provided. this is Bucket
  3. .s3.amazonaws.com/
  4. fileName provided. This is Key

Since we can’t change the format of coding or URL or function provided by AWS, thus more important then format is Does URL does what you want it to do? Is this URL able to download s3 file and expire after 60 seconds?

Do follow these docs over AWS signed URL.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement