Search code examples
amazon-web-servicesamazon-s3aws-java-sdk

S3 putCustomQueryParameter to return by LastModified?


Using the aws cli I can send a --query to return only the objects since LastModified:

aws s3api list-objects --profile <profile> --bucket <bucket>  --query 'Contents[?LastModified>=`2017-01-19`][]'

Works great, returns only objects >= the date.

I'm trying to translate this to the Java SDK with something like this:

ListObjectsV2Request req = new ListObjectsV2Request();
req.putCustomQueryParameter("LastModified>=`2017-01-19`", null);

I've tried a large number of variations on the both the query and parameter strings without any luck- the query always returns all objects. So two questions:

  1. Should this work? That is is this something putCustomQueryParameter should do?
  2. What's the correct syntax if the answer to #1 is 'Yes'?

Thanks in advance.


Solution

  • This isn't possible in the way you envision it.

    The cli is actually listing all the objects and filtering them locally. The API (which is what the cli, SDKs, and console all use) doesn't support such a query.