-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create a directory in a bucket using boto3 ? #377
Comments
I'm pretty sure that S3 has no concept of a directory. It's designed as a key-value store, so everything within a bucket is stored on the same 'level'. If you really want a directory-like structure (restricted to two-deep), then you can use multiple buckets. |
Thx @themanifold |
@tuxknight You would upload an empty file whose name ends with a |
for anyone else who comes along not realizing immediately what this would entail, this is how i did it: import boto3
client = boto3.client('s3')
response = client.put_object(
Bucket='my-top-level-bucket',
Body='',
Key='test-folder/'
) |
@ryantuck Thanks, Looks like its possible with boto 3, I am trying to build directory tree like structure in s3, so for every client there is separate folder & separate sub folders for their orders placed in site. I am pretty sure we can build a very nice structure on s3, My question is this, Can we also build a file manager or file browser inside our application on top of s3 for all the client files, I am thinking of something similar like dropbox or google drive. SO I am wondering if this can be done on top of s3 file structure & there also be restriction on files to be accessed by some users. Sorry, If my question is not clear. |
@ryantuck hi bro it's very good code but I have a doubt what if I want to put three folders at a time in the bucket. |
@webraj1 you would probably want to use separate buckets for that. google or aws docs would probably be more helpful for telling you if you can restrict access to certain roles within the same bucket. @phanimahi my guess is that you would not put them in 3 at a time, but rather one after the other? |
Just wondering, if you got it working? I'm at the same cross-roads |
Does boto3 support creating directory ?
Will it create a directory name "dir" when I put an object with a key such as "dir/file.png" ?
The text was updated successfully, but these errors were encountered: