I want to add Folder in my amazon s3 bucket using coding. Can you please suggest me how to achieve this?
Java with AWS SDK:
There are no folders in s3, only key/value pairs. The key can contain slashes (/
) and that will make it appear as a folder in management console, but programmatically it's not a folder it is a String value.
If you are trying to structure your s3 bucket, then your naming conventions (the keys you give your files) can simply follow normal directory patterns, i.e. folder/subfolder/file.txt
.
When searching (depending on language you are using), you can search via prefix with a delimiter. In Java, it would be a listObjects(String storageBucket, String prefix, String delimiter)
method call.
The storageBucket
is the name of your bucket, the prefix
is the key you want to search, and the delimiter
is used to filter your search based off the prefix
.