[Rails] file uploads

Scott Barron scott at elitists.net
Wed Jan 12 20:38:19 GMT 2005


Joe Van Dyk wrote:
> On Wed, 12 Jan 2005 12:26:47 -0800, Joe Van Dyk <joevandyk at gmail.com> wrote:
> 
>>On Wed, 12 Jan 2005 12:26:27 -0800, Joe Van Dyk <joevandyk at gmail.com> wrote:
>>
>>>On Wed, 12 Jan 2005 18:48:42 +0100, Alexander Staubo <alex at byzantine.no> wrote:
>>>
>>>>Joe Van Dyk wrote:
>>>>
>>>>>I saw a thread on here earlier about file uploading, particularly with pictures.
>>>>>
>>>>>How does one do the controller/view part for a file upload?  I tried
>>>>>it, but all I could get the controller to see was the file name of the
>>>>>file that the user picked.
>>>>
>>>>There's a nice howto here:
>>>>
>>>>   http://wiki.rubyonrails.com/rails/show/HowtoUploadFiles
>>>
>>>What are the benefits vs drawbacks of using the database to store images?
>>>
>>>As far as I can see:
>>>
>>>Benefits: All data contained in one place
>>>Pros: Worse for performance as more load placed on database
>>
>>And another pro: backups become larger.
>>
> 
> 
> Pros should be Cons.  :(  Long day.

Tell me about it ;).  But, the backups don't necessarily become larger. 
  If you're keeping images out of the db and pointing to them, you still 
need to back them up or you could have dangling references after you 
restore.

When I make such a decision I usually just consider what the size of the 
database and the number of images might be.  For example, I have a 
scheduling app for the university cable station that keeps cover art 
images for movies they're playing.  This is a small DB and keeping the 
images in the DB really doesn't cost me anything performance-wise.  In 
this application I even go so far as to base64 encode the images before 
dumping that into the DB.  That, however, can add overhead.

A few months ago I interviewed for a company that had an application 
(PHP) that would recieve over 60,000 PDF uploads per day.  Since I was 
just interviewing with them they didn't tell me everything about their 
set up, but for this guy keeping the PDFs in his DB (they were using 
MySQL) was not an option for him.  I am not entirely sure if MySQL can 
handle this or not, I don't work with that kind of load here, but on 
that scale it seems that it could be an important decision.

So, really, I think the scope of one's application will weigh more on 
one's decision.

The day is almost over :)
-Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050112/7c5b83ad/signature.bin


More information about the Rails mailing list