javascript – 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?

Read more here: Source link