tags:

views:

62

answers:

2

So it just occurred to me that once I upload profile pics to S3, I have to figure out a way to keep track of the files. For example, if "susan" uploads 3 profile pics, I need to recall those 3 pictures and display it on her profile page if someone views her page. With that said, would the following work?

  • User uploads picture from form
  • Save file information (filename, user info, etc...) into DB and reference URL from S3
  • Upload photos to S3

When displaying pictures, I'll query the DB for the info and display the images from S3 accordingly.

A: 

You should not store the full URLs in the database, just the file names. The URLs will all be consistent with this pattern:

http://s3.amazonaws.com/YOUR-BUCKET-NAME/YOUR-FILE-NAME

So you just need your constant bucket name and file name.

This way you can change how you serve the files and only change your app, not the data in the database (for example, if you start using CloudFront instead of direct S3 access).

Sam
correct, sorry yea I would store the filename.
luckytaxi
A: 

ended up using GridFS from MongoDB.

luckytaxi