Re: yet another image: db or filesystem ? question - Mailing list pgsql-general

From PFC
Subject Re: yet another image: db or filesystem ? question
Date
Msg-id op.tvmd5bt3cigqcu@apollo13
Whole thread Raw
In response to yet another image: db or filesystem ? question  (Rick Schumeyer <rschumeyer@ieee.org>)
List pgsql-general
> 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



pgsql-general by date:

Previous
From: Zlatko Matić
Date:
Subject: Re: ERROR: a column definition list is required for functions returning "record"
Next
From: Matthew Terenzio
Date:
Subject: Re: PHP pg_connect