I'm getting a pre-signed URL to upload a file on S3 bucket.
this is the curl command:
curl -v -T ./dansero.jpg 'https://ss-files-dev.s3.ap-southeast-2.amazonaws.com/dansero.jpg\?AWSAccessKeyId\=AKIAIT6VM43PPNS43Y7Q\&Expires\=1531973770\&Signature\=hNvG5rnICkk58mMBLeMgHGDZ93c%3D'
That gives me the error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
</Error>
Here my node.js generation of the presigned URL
var AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: 'aaa',
secretAccessKey: 'bbb+oeyjn8zGANuDyCIY',
region: 'ap-southeast-2'
});
const params = {
Bucket: 'ss-files-dev',
Key: 'dansero.jpg'
};
});
s3.getSignedUrl('putObject', params, function(err, urlsign) {
if (err) console.log(err);
console.log(urlsign);
});
So where is my problem in the URL generation or the curl?
thanks
Best Answer
I can't see the sign request part. Make sure get signed URL for put object. It is working code from my script:
Try put the object into your bucket by simple put request like this:
Finally, make sure about the following things:
1-User policy and right IAM for your key. You should have the permission to put objects like this:
2- I think you should pass -X PUT in your curl request.