User sdk version : aws-sdk-2.283.1.min.js
I use like this:
var myCredentials = new AWS.Credentials("key",
"secret");
var config = new AWS.Config();
config.update({
region: "cn-north-1",
credentials: myCredentials
});var s3 = new AWS.S3(config);
var p2 = {
Bucket: 'equipment-firmware', Key: 'test/func.jpg', ResponseContentDisposition: 'attachment', Expires: 6000
};
s3.getSignedUrl('getObject', p2, function (err, url) {
if (err) {
console.log(err, err.stack);
} else {
console.log('The URL is', url);
window.open(url);
}
});
But use return url, in browser status is 401 and show this:
<Error>
<Code>UnauthorizedAccess</Code>
<Message>You are not authorized to perform this operation</Message>
<RequestId>649CEE7A351D2549</RequestId><HostId>RUWINnJ4IHsN7Jicb6oI7L87ZfYFC5J+c3fmLgwkTqJ+G+AvvAD7scLZDKUBFzZxC+Bg7HaNua4=</HostId>
</Error>
Comments
Post a Comment