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
on 2007-03-09 09:20
on 2007-03-09 09:30
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
on 2007-03-09 09:57
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.
on 2007-03-09 10:45
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.
on 2007-03-09 10:57
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.
on 2007-03-11 14:24
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.
on 2007-03-11 15:17
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.
on 2007-03-11 15:52
Dear Eleo, thanks for your fast reply but can you elaborate more "if this doesnt bother you, I am a NOOB :)"? thanks agin.