Hi Pete,
I''m currently storing binary files in the database for various reasons,
however I have a caching system in place where after saving the file to
the DB a cached copy of the binary file is stored on the file system. I
keep track of the file location in the database as well. This way I have
the best of both worlds.
Cheers
Jonathan
Pete wrote:> Hi everyone,
>
> in order to organize product images I currently see these options:
>
> - put images into ''public'' folder and reference them by
name from db record
>
> > store ''main.jpg'' ->
/public/product_images/123/main.jpg
>
> > insert into products(id, ..., image) values(123, ...,
''main.jpg'')
>
> html: <img src="/product_images/123/main.jpg">
>
> pro:
> + fast?
> con:
> - integrity risk - filename and folder can be out of sync
> - hot backup is difficult as file systems does not support snapshots
>
> - put the image into the record itself using a BLOB datatype
>
> create table products(
> id integer,
> image mediumblob
> )
>
> html: <img src="/mycontroller/view_action/123">
>
> pro:
> + image and record are always in sync
> con:
> - loading data from record is probably slower
>
> Which one do you guys prefer? is database significantly slower than
> filesystem?
>
> I am using MySQL 5 and images are between 15KB to 5MB...
>
>
> Best regards
> Pete