0

looking for help with deleting empty folders from AWS S3 bucket

I have a Apex class which makes callouts to download and delete files from an AWS S3 folder using HTTP Request. I would like to delete the folder after all files are downloaded (when folder is empty), however I don't know how to check first if the folder is empty before deleting it.

Any suggestions would be highly appreciated.

2
  • What about DescribeFolderContents call to check what is inside folder (docs.aws.amazon.com/workdocs/latest/APIReference/…)?
    – kurunve
    Jan 14 at 8:46
  • Thanks for the suggestion. Would my HTTPRequest code look like this? And where would I find the folder id in S3? What should be the endpoint? String url = 'callout:AWS_S3'; HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); req.setEndpoint(url + '/api/v1/folders/FolderId/contents'); req.setMethod('GET'); Http http = new Http(); res = http.send(req);
    – Lena
    Jan 14 at 9:47