jeudi 7 décembre 2017

Saving images to S3 per bucket or pure Type with Ruby gem

I am just starting to write several images to S3. I will have 4 to 10 images per case per user.

User > Case > images

My plan is to create a bucket per case, but wondering if I should instead save all images with a prefix in the key and have all images for all cases in one bucket?

MyBucket > 2sk67o3/waiver/image1-big.jpg
MyBucket > 2sk67o3/waiver/image1-small.jpg
MyBucket > 2sk67o3/merchandise/image1-big.jpg
MyBucket > 2sk67o3/merchandise/image1-small.jpg

OR

MyBucket_2sk67o3 > waiver/image1-big.jpg
MyBucket_2sk67o3 > waiver/image1-small.jpg
MyBucket_2sk67o3 > merchandise/image1-big.jpg
MyBucket_2sk67o3 > merchandise/image1-small.jpg

I am thinking the last version is correct in that I can use the "with_prefix" provided by the Ruby gem to find images easier to delete or replace them? For instance, to delete the "waiver" I will, of course, want to delete both the big and small image.

bucket.objects.with_prefix('waiver').collect(&:key)

I guess I could just do the first way, above, and search the prefix '2sk67o3/merchandise'. So the question remains better, easier, standard for a bucket per Case or one giant bucket?

Aucun commentaire:

Enregistrer un commentaire