Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 JavaScript SDK getSignedUrl returns base path only

I have some very simple code for generating an S3 URL. The URL I get back from the SDK only has the base path for S3. It doesn't contain anything else. Why is this happening?

var AWS = require('aws-sdk');

var s3 = new AWS.S3();

console.log(s3.getSignedUrl('getObject', {
  Bucket: 'test',
  Key: 'test'
}));

// Returns "https://s3.amazonaws.com/"

Node.js v0.12.0, AWS SDK 2.1.15 or 2.1.17, Windows 7 64-bit,

like image 905
Brad Avatar asked Mar 14 '15 02:03

Brad


Video Answer


2 Answers

The problem wasn't with code. It turns out that when you don't have your AWS credentials set up properly in your environment that the AWS SDK doesn't complain. Fixing the credentials in ~/.aws/credentials resolved the issue.

like image 107
Brad Avatar answered Oct 19 '22 18:10

Brad


I too had the same problem. I got the correct output by changing the below

from AWS_Access_Key_Id = myaccesskey to aws_access_key_id=myaccesskey

Similarly for Secret key. That means you should not use Upper case and no space before and after =

like image 34
Shambhavi_RB Avatar answered Oct 19 '22 18:10

Shambhavi_RB