login community faq

I am working on an Rails 3 application which accepts user uploaded image. Currently the images are getting stored inside the public dir of my app.

But considering a scenario where I want to upgrade my rails app to a new one, I will always have to keep this public directory same for all versions of my app in order for the DB to exactly retrieve and thus show the image. Basically the link / path to the image is stored in the DB and the actual image is getting stored inside the public dir of the app.

I have read many links to understand the way the uploaded images, etc needs to be stored and have come across 2 approaches: File System Storage VS Database Storage. Due to performance and various other reasons, I prefer the File System Storage option but I am confused as how should I design it.

Definitely storing in public folder of the app is not a good idea. I also thought of storing in another dir under my ~/webapps/ and then have my app always access this path for images. This way they both remain decoupled. But again in this approach, I have to still maintain and ensure that the web apps folder always remains fine and is backed up regularly for restoration purpose.

Can someone please suggest me and guide me the correct design approach? I am sure most of the common web apps demands images to be stored and there is some standardized way for the same.

Thanks for your help and response.

asked Jun 14 '12 at 06:03

talktoari's gravatar image

talktoari
53


File system storage is usually better from performance point of view - so you are on the right track there.

You can store these files under ~/webapps/appname provided that's outsite the web root of the app (as defined in your nginx.conf file). You could also store in any folder under your home directory - it's up to you, and as far as I'm aware there's no standard or best practice that would suggest storing those files in a certain location.

Regarding backing up that folder, you can schedule a cronjob to do that for you - again, it doesn't matter where on the filesystem this folder is located, it just needs to be referenced correctly by your cron script.

If you run into any troubles setting this up, feel free to post a comment to this answer, or open a ticket.

answered Jun 14 '12 at 07:06

todork's gravatar image

todork
10964

edited Jun 14 '12 at 07:06

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×79
×20
×4
×4
×1

Asked: Jun 14 '12 at 06:03

Seen: 686 times

Last updated: Jun 14 '12 at 07:06

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited