获取位于特定S3文件夹下的对象的列表 [英] GET list of objects located under a specific S3 folder
问题描述
我正在尝试使用查询字符串获取S3存储桶中特定文件夹下的对象列表,该查询字符串以文件夹名称为参数,并使用Node JS aws-sdk列出与该特定文件夹匹配的所有对象>
例如: http://localhost:3000/listobjects?foldername = xxx >
请提出如何实现此功能的建议.
您可以在aws-sdk
中调用 getObject
或 listObjectsV2
时指定前缀. var params = {值区:"STRING_VALUE",/*为必填项*/前缀:"STRING_VALUE"//可以是您的文件夹名称};s3.listObjectsV2(params,function(err,data){如果(err)console.log(err,err.stack);//发生错误其他console.log(data);//成功回应});
顺便说一句,S3没有文件夹.它只是一个前缀.它显示了文件夹结构,使您也可以轻松浏览和查看文件.
I am trying to GET a list of objects located under a specific folder in an S3 bucket using a query-string which takes the foldername as the parameter and list all objects which match that specific folder using Node JS aws-sdk
For example: http://localhost:3000/listobjects?foldername=xxx
Please suggest how to implement this functionality.
You can specify the prefix while calling the getObject
or listObjectsV2
in aws-sdk
var params = {
Bucket: 'STRING_VALUE', /* required */
Prefix: 'STRING_VALUE' // Can be your folder name
};
s3.listObjectsV2(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
By the way, S3 doesn't have folders. It is just a prefix. It shows you the folder structure to make it easy for you too navigate and see files.
Source: AWS SDK Javascript
这篇关于获取位于特定S3文件夹下的对象的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!