本文介绍了如何使用amazon-javascript-sdk列出AWS S3存储桶?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取具有客户端accessKeyId和secretAccessKey的存储桶的列表.从文档中我了解到,我必须更新AWS的配置,创建一个新的S3对象,然后使用回调对其调用listBuckets()函数.
I need to get a list of buckets having the client accessKeyId and secretAccessKey. From the docs I understood that I have to update de configurations of AWS, create a new S3 object, then call on it the listBuckets() function with the callback.
所以,这是我的代码:
AWS.config.update({
accessKeyId: awsKey.identifier, secretAccessKey: awsKey.secret, region: awsKey.region,
apiVersion: '2006-03-01'
});
let s3 = new AWS.S3();
s3.listBuckets((response, data) => {
console.log(response);
console.log(data);
});
问题是我得到:
感谢您的关注
推荐答案
在AWS论坛上,我得到一个回答,说不可能在浏览器中使用amazon-javascript-sdk来做到这一点.
On the AWS Forums I got an answer that says it's impossible to do that, using amazon-javascript-sdk in the browser.
这里是帖子: https://forums.aws .amazon.com/thread.jspa?threadID = 179355& tstart = 0
这篇关于如何使用amazon-javascript-sdk列出AWS S3存储桶?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!