Search Postgresql Archives

Re: yet another image: db or filesystem ? question

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

 




a) if the images are in the filesystem (and also under the web root), no problem. Just use <img src="filename.jpg" />

b) if the images are in the database...

You use <img="images/filename.jpg" /> and setup URL rewriting in your webserver so that a HTTP request on "images/filename.jpg" becomes "serve_image?fname=filename.jpg" with serve_image being a php, jsp, whatever script. This way when the performance starts to suck too much you can simply serve images off the filesystem very easily, just remove the URL rewriting. Please use your primary key (an integer) as filename, don't let the users name files on your filesystem !!

If you are trying to control user access rights to files, it is much faster to use an authenticator plugin, or lighttpd's mod_sec_download.

In both cases the web application is only invoked to decide if the user can access the image or not ; it does not actually handle the (potentially large) file. It is the webserver that does it, and webservers are optimized for this purpose.

If it's for an intranet where you don't expect lots of traffic, though, the PHP echoing a bytea it got from postgres works well...


do I need to create a temporary file first in order to use the <img> tag? Or is there some other HTML way of doing this?



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux