Best way to store binary data

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 :slight_smile: in advance…

Amr M. Kamel

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 :slight_smile:
Thanks again.

On 9 Mar, 09:29, “mohan” [email protected] 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.

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

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.

Dear Eleo,
thanks for your fast reply but can you elaborate more “if this doesnt
bother you, I am a NOOB :)”?
thanks agin.

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.

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.