How to add an S3 folder within a bucket

If anyone could help that would be awesome.
I have a bucket which when I upload a file into it, it works no problems.
However, I want to create a folder within the bucket to hold different files (the folder name will be dynamic)
As soon as I try and do this, it just does not work.
Can anyone give me any ideas on the process to do this.

Thanks

Folders are simply added as part of the Key. So you can use:

food/apple.jpg
food/candy/bad-for-you.png

which will create a food folder with apple.jpg inside it, as well as another folder, candy, also with a file inside it.

1 Like