Reputation: 5067
We are in the dev phase. We were planning to use a dedicated infrastcrutre but swapped the decision to AWS cloud.
The directory structure regarding uploaded images was implemented like:
web_root\{year}\{month}\{day}\{type}_{filename_md5_hash}.jpeg
Where the type is either s
for small image or o
for original size. The small image is created using a filter.
The problem is that I heard AWS S3 doesn't give you control over the directory structure inside a bucket.
Your invaluable explanations were always of great help. Thanks
Upvotes: 1
Views: 8537
Reputation: 596246
This is covered in the AWS S3 documentation:
In Amazon S3, buckets and objects are the primary resources, where objects are stored in buckets. Amazon S3 has a flat structure with no hierarchy like you would see in a typical file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. Amazon S3 does this by using key name prefixes for objects.
For example, you can create a folder in the console called
photos
, and store an object calledmyphoto.jpg
in it. The object is then stored with the key namephotos/myphoto.jpg
, wherephotos/
is the prefix....
You can have folders within folders, but not buckets within buckets. You can upload and copy objects directly into a folder. Folders can be created, deleted, and made public, but they cannot be renamed. Objects can be moved from one folder to another.
So, you can indeed upload files to S3 using a similar folder structure in your bucket:
http://{bucket}.{endpoint}.amazonaws.com/web_root/{year}/{month}/{day}/{type}_{filename_md5_hash}.jpeg
Or
http://{endpoint}.amazonaws.com/{bucket}/web_root/{year}/{month}/{day}/{type}_{filename_md5_hash}.jpeg
Upvotes: 9
Reputation: 56877
S3 isn't a normal filesystem and it doesn't have a file structure as such but it does have nested keys for the object references and even kind of pretends that it's filesystem like with the API (you use aws s3 ls
to list a bucket and then kep using it as you move through the object tree much like you might with a file system).
So if you want to create an object called foo_ashdbasd.jpeg
and normally you'd want that to sit in a folder structure like this web_root\2016\06\15
then you simply write to an object in your S3 bucket called web_root/2016/06/15/foo_ashdbasd.jpeg
.
Upvotes: 3