I am trying to fetch the objects of the AWS S3 bucket using PHP AWS API V3 (ListObjectsV2). I am not able to find any perfect source or documentation to filter the result by specific date or other values.
I want to create a script for fetch daily updated objects to our database and server using PHP SDK.
$command = $s3->getCommand('ListObjectsV2');
$command['Bucket'] = 'TestBucket';
$command['MaxKeys'] = 10;
$date = '2020-04-30';
$command['Query'] = "Contents[?LastModified.date>='${date}']";
$objects = $s3->execute($command);
I have achieved my goal by putting below condition with search
$serach_expression = "Contents[?(contains(Key, '.jpg') || contains(Key, '.jpeg') && LastModified[?date>=2020-05-01])].{Key: Key, Size: Size, LastModified: LastModified}";
$items = $objectInfo->search($serach_expression);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.