Forum: Ruby on Rails Best way to store binary data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F197afc0b39c9dd813a468701b2b92b0?d=identicon&s=25 Amr Kamel (amrkamel)
on 2007-03-09 09:20
(Received via mailing list)
Dear all,
can any one tell me what is the best way to store binary data "e.g.
images, videos ...etc" of various sizes in a ROR application? should I
store them in mysql database or in file system?
Thanks alot :) in advance..

Amr M. Kamel
E5cacdc96d55a0a6c70f5025eab3b079?d=identicon&s=25 mohan (Guest)
on 2007-03-09 09:30
(Received via mailing list)
U can store the binary data in mysql database. i think it is a best
way(suppose u have lak of lak image db volume will be huge, but i
think thats not big problem).

Mohan
F197afc0b39c9dd813a468701b2b92b0?d=identicon&s=25 Amr Kamel (amrkamel)
on 2007-03-09 09:57
(Received via mailing list)
Thanks alot for your very fast reply, and for database volume we can
always solve it by adding extra hard disks and maybe use one of RAID
technologies :)
Thanks again.
25e782eb7e799e78d781b0026fc6a4d8?d=identicon&s=25 Claudio Poli  (Guest)
on 2007-03-09 10:45
(Received via mailing list)
On 9 Mar, 09:29, "mohan" <mohan...@gmail.com> wrote:
> U can store the binary data in mysql database. i think it is a best
> way(suppose u have lak of lak image db volume will be huge, but i
> think thats not big problem).

it's a way, but it isn't the best.
databases will grow in size, creating problems for portability, backup
dumps and speed.
if you have a small amount of data storing binary data in database
seems a good idea, for every other thing fs is the way to go, at least
for me.
A0f6b57661bc57b6520010a2a333faba?d=identicon&s=25 R. Elliott Mason (eleo)
on 2007-03-09 10:57
(Received via mailing list)
I don't think it is a good idea.  I can't think it would be any better
than saving the actual files.  Having to pull images out of the
database will probably add dramatically to database bandwidth over
time.

Probably the only advantage is that saving to database is probably
easier to do; requires less code.

I personally choose to save the actual files to the file system and
store info about the file (width, height, filesize, md5, etc) to
database.
F197afc0b39c9dd813a468701b2b92b0?d=identicon&s=25 Amr Kamel (amrkamel)
on 2007-03-11 14:24
(Received via mailing list)
Thank you all for your help :),
Eleo, I like your idea but I should add also a column that stores file
location on the file system "as a pointer" to be able to fetch the
file? is this correct? or if there is a better approach plz let me
know it..
Thanks alot.
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-03-11 15:17
(Received via mailing list)
That's one way.  Another is to setup some convention whereby you can
calculate the file location based on the record ID or some other
signifying data point in your model.  This'll make it easier to scale
if you need to in the future.
F197afc0b39c9dd813a468701b2b92b0?d=identicon&s=25 Amr Kamel (amrkamel)
on 2007-03-11 15:52
(Received via mailing list)
Dear Eleo,
thanks for your fast reply but can you elaborate more "if this doesnt
bother you, I am a NOOB :)"?
thanks agin.
This topic is locked and can not be replied to.