I set the key of files in Amazon S3 to be folder\filename. Is there a way to get all the files under a "folder" (search files by regex)?
You tagged your question with aws-sdk
but did not mention a language, so I'll use Python in this answer.
The list_objects_v2()
command accepts a Prefix
:
response = client.list_objects_v2(
Bucket='string',
Delimiter='string',
EncodingType='url',
MaxKeys=123,
Prefix='string',
ContinuationToken='string',
FetchOwner=True|False,
StartAfter='string',
RequestPayer='requester'
)
If you set Prefix='folder/'
, then it will return objects within that folder.
However, it is not possible to use a Regex expression. Your program will need to filter the return list to meet your needs.
I hope provided link will answer your question.
AWS S3 object listing
You can also get list of objects by using aws-cli
Type following command in terminal
aws s3 ls bucketName/folderName/
Here '/' is necessary at the end of folder name, else you will get only folder name in result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With