I have the following folder structure that I would like to create in S3,
/demo/app/a.txt
Via Console:
demo and app using "Create Folder", followed by a.txt file upload
Via CLI:
aws s3 sync . s3://<my-bucket>/, where . (current dir) has demo folder
--
Now when I run,
aws s3 ls s3://<my-bucket> --recursive, the result is quite interesting/puzzling!
Output:
# created & uploaded from console
demo/
demo/app/
demo/app/a.txt
# from CLI
demo/app/a.txt
Clearly, there aren't any prefixes/objects for demo/ and demo/app/ created using CLI upload.
--
This answer helped me understand that "Create Folder" from console results in creating a 0-byte file when the folder is empty. But this isn't the case when uploaded via CLI.
So, how do I mimic the 0-byte file behavior for CLI uploads? In other words, match the prefixes!
The other use case is, navigating across directories from a browser will not work as the prefixes aren't available. For e.g.
- Uploaded from console:
https://<domain>/demo/showsappdirectory. - Uploaded from CLI:
https://<domain>/demo/results inNoSuchKeyError
--
Note: I'm using a CloudFront distribution to access S3 data (if that helps)!