[英]AWS S3 getObject JS SDK
I am using JS SDK 2.7.13 for AWS. 我正在使用适用于AWS的JS SDK 2.7.13。 I can not seem to getObject from S3 using a web browser.
我似乎无法使用Web浏览器从S3中获取Object。
i tried the code listed here 我尝试了这里列出的代码
getS3Object(){
AWS.config.region = 'us-east-1';
AWS.config.update({
credentials: new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:00000000-0000-0000-0000-000000000000'
})
});
AWS.config.credentials.refresh(function(){
let s3 = new AWS.S3({region: 'us-east-1', params: {Bucket: 'BUCKET NAME'}});
let params = {
Bucket: 'BUCKET NAME',
Key: "NAME OF FILE I WANT"
};
s3.getObject(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
});
}
I get 我懂了
Error: Missing credentials in config
and 和
"NotAuthorizedException: Missing credentials in config
i can get the item if i use the url path but i also want to upload later on so i would need this to work. 如果我使用url路径,则可以获取该项目,但我也想稍后再上传,因此我需要使用它。
You need to get temporary access credentials from AWS cognito and update AWS.config.credentials
. 您需要从AWS cognito获取临时访问凭证并更新
AWS.config.credentials
。 Refer this link for more details. 请参阅此链接以获取更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.