Switching to Amazon S3. Saving my hierarchical directories?

I have a Rails 3 app with a pearl Paperclip. In fact, my local directory structure is based on my UUID record on stock images:

5D5E5641-FCE8-4D0B-A413-A9F993CD0E34 

becomes:

 5/D/5/E/5/6/....... 3/4/full/image.jpg 5/D/5/E/5/6/....... 3/4/thumb/image.jpg 

so I will never have more than 32,000 nodes in the directory.

I want to switch to S3: 1) Can I keep this directory structure on S3? Could this be a problem? 2) Does Amazon S3 have its own directory management per bucket?

Thanks.

+3
source share
1 answer

Amazon S3 has no such thing as folders. This is a flat file system. The closer you can get to the folders, so add prefixes, as you said: 5/D/image.jpg to your file names. In this case, 5 is a prefix, and 5/D also a prefix. On the other hand, your delimiter may be / .

Although several S3 tools will show you things as if they were contained inside folders, this concept does not exist on S3. Check out this and this related threads.

You can definitely use the template you suggested, and I don't think you will incur any performance penalties by doing this.

0
source

Source: https://habr.com/ru/post/1480385/


All Articles