Reputation: 54949
I am have an app that will require to use Amazon S3 to host Images and its different sizes on it. I am looking forward to understand which is the best way to do this.
When a user uploads an Image i create 3 different sizes that are required at different parts of the site or the mobile app. In total i have 4 files of the same images.
Questions:
Upvotes: 0
Views: 141
Reputation: 46301
You could simply append a short string, either the resolution or a usage-identifier like 'thumbnail', e.g.
foobar.jpg -> 2342342_thumb.jpg
-> 2342342_gallery.jpg
-> 2342342_full.jpg
That way, you won't need to store the name of the four files but just follow the convention.
Upvotes: 1
Reputation: 2579
You don't need to keep all file names in db. Just keep a parent folder name.
Lets say an image uploaded by a user has id 1234567(for sake of uniqueness. You may also use timestamp). Then create a folder named 1234567 and put all images with specific names like original, thumbnail, medium, large. And whenever you need a specific one just stream it.
Upvotes: 1