简体   繁体   English

AWS S3:如何按标签列出对象

[英]AWS S3: how to list object by tags

I created objects with tag with following snippet of code我用以下代码片段创建了带有标签的对象

PutObjectRequest putRequest = new PutObjectRequest(bucketName, keyName, new File(filePath)); 
List<Tag> tags = new ArrayList<Tag>();
tags.add(new Tag("Key1", "Value1"));
tags.add(new Tag("Key2", "Value2"));
putRequest.setTagging(new ObjectTagging(tags));
PutObjectResult putResult = s3client.putObject(putRequest); 

I get list of objects with code我得到带有代码的对象列表

s3client.listObjectsV2(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);  
}

My question:我的问题:

how to get list of objects filtered by tags ?如何获取按标签过滤的对象列表?

If impossible to filter by tag, what is the purpose of tag that S3 introduced?如果不能按标签过滤,那么S3引入的标签的目的是什么?

One option is the use the Resource Groups Tagging API function.一种选择是使用资源组标记 API 功能。 You'll find documentation for javascript here: AWS Javascript API Reference for Resource Groups Tagging API您可以在此处找到有关 javascript 的文档: AWS Javascript API Reference for Resource Groups Tagging API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM