I have a simple Node.js app. I'll have user profiles and each user can upload several images. The images will be uploaded to Rackspace Cloudfiles.
I am currently using the Rackit module.
The way it works currently:
I pass Rackit a file, which uploads it to Rackspace Cloudfiles, and returns the CDN url to that image (image name has been hashed by rackit) (url looks something like this):
http://c15142174.r14.ca2.rackcdn.com/Y20h30Jd918aHV3pKROzejdq
Rackit currently saves all the images into ONE container.
Here are my questions:
1) Should I save each user's images into a separate container (for privacy, security, and to make sure one user can't erase another users)?
2) Would it be sufficient to simply store the url ref above in a database and reference it that way in the future? Can I count on this url not changing?
3) Would it make more sense to prefix a user's image with a username or hash that ties the images to a given user?
What's the best practice approach?
Thank you
I was referred to this great article that really answered my questions very well: http://www.rackspace.com/knowledge_center/content/best-practices-using-cloud-files
To sum up the article for my use case:
1) Use multiple containers. Having lots of images in one container slows you down, especially since there's a throttle on how frequently you can write to the same container. This could be especially problematic if 2 users are simultaneously trying to upload images to the same container. Hence a different container for each user makes sense here.
2) You can use pseudo folders for organization if needed. You can name your image (it's an object in rackspace cloud) "/user123/ducks/duck_small.jpg". In this scenario the name of the image is that entire string (including the slashes).
3) Store references to the images in your database. Accessing cloudfiles to list the contents of the container would be MUCH slower than simply getting the cdn url for the image from your database.