Re: Alternative methods for storing uploaded images?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All makes good sense.

Will check out code, etc.

Thanks

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Carl Roett" <carlroett@xxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Thursday, May 10, 2012 11:41 PM
Subject: Re:  Alternative methods for storing uploaded images?


The answer is "it depends" and in some very specialized situations storing
binaries in the database might be the best solution. But in general, this
approach will cause you serious problems.

Some ramifications:

1) Browsers won't cache the images. So you'll take a CPU and bandwidth hit
every time
2) MySQL stores encoded binary data in a separate part of the database.
Your files probably won't get held in the memory cache. So each file load
carries the same penalty as a loading the raw file from disk.
3) It will make your database huge. Which will make it very challenging to
import, export, and move between test servers. Its easy to write scripts
that can handle content files that are missing from the server, but a
database is an atomic "all or nothing" thing.
4) Makes it difficult to manually edit things in the database.

My team is building a huge (hundreds of thousands of LOC) image management
plugin for WordPress. Have a look at our code and see how we solve these
problems. Specifically, look at the disk cache classes.

http://code.google.com/p/buddypress-media/source/browse/#svn%2Fbp_media%2Ftrunk


^C^

==================================

On Thu, May 10, 2012 at 12:07 PM, Jacob Kruger <jacobk@xxxxxxxxxxxxxx>wrote:

Just wondering if it's better to either store uploaded images, via
something like a form of CMS, in a static folder, with a unique name based
on something like the data record's id field, when keeping track of it's
location like that, or is it better to actually store the binary data of
the image file in the mySQL database itself, and then sort of stream it
back out when displaying the image, and if so, would presume that would be relatively simple to implement, but, OTOH, if you were then using the data to then render static content output for later use, it would, obviously, be
better to keep the image content static as well...?

Thoughts/examples?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'




--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux