javascript - Format of S3 pre-signed URLs - Stack Overflow

I'm trying to create an S3 pre-signed URL in my JavaScript code using: var params = {Bucket: '

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 .mp3...

but I think it should be showing:

The URL is .mp3...

Why would it place the S3 bucket name before "s3.amazonaws" in the URL?

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

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./myAudioFile.mp3...

but I think it should be showing:

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

Why would it place the S3 bucket name before "s3.amazonaws." in the URL?

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

Share Improve this question edited Oct 25, 2018 at 20:04 jarmod 79k18 gold badges130 silver badges135 bronze badges asked Oct 25, 2018 at 17:56 HackbrewHackbrew 5132 gold badges12 silver badges26 bronze badges 4
  • 1 Your bucket is accessible either way. Is this causing a problem? – Brad Commented Oct 25, 2018 at 19:57
  • 1 Note that bucket.s3.amazonaws./cat.png is a virtual-hosted–style URL, while s3.amazonaws./bucket/cat.png is a path-style URL. Both are valid. – jarmod Commented Oct 25, 2018 at 20:06
  • Both are valid only for buckets in us-east-1. Path-style must reference the regional endpoint, otherwise, e.g. https://s3.us-east-3.amazonaws./example-bucket for us-east-2. – Michael - sqlbot Commented Oct 26, 2018 at 0:43
  • What is the actual problem you are experiencing? – Michael - sqlbot Commented Oct 26, 2018 at 0:44
Add a ment  | 

1 Answer 1

Reset to default 3

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./
  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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745047193a4608171.html

相关推荐

  • javascript - Format of S3 pre-signed URLs - Stack Overflow

    I'm trying to create an S3 pre-signed URL in my JavaScript code using: var params = {Bucket: '

    8小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信