X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id CD74C30EEC7 for ; Tue, 17 Jun 2003 23:18:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 08105-02 for ; Tue, 17 Jun 2003 20:18:10 -0300 (ADT) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by svr1.postgresql.org (Postfix) with ESMTP id 52CDA30DC8A for ; Tue, 17 Jun 2003 20:18:08 -0300 (ADT) Received: from oasis.net.au (guardian [210.8.139.5]) by water.oasis.net.au (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id JAA08356 for ; Wed, 18 Jun 2003 09:33:23 +1000 X-Authentication-Warning: water.oasis.net.au: Host guardian [210.8.139.5] claimed to be oasis.net.au Message-ID: <3EEFA1CB.20303@oasis.net.au> Date: Wed, 18 Jun 2003 09:18:35 +1000 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-sql@postgresql.org Subject: Re: Blobs with perl References: <00e001c334ae$d93e52c0$7201a8c0@aaa> <200306170730.44746.jgardner@jonathangardner.net> In-Reply-To: <200306170730.44746.jgardner@jonathangardner.net> Content-Type: multipart/alternative; boundary="------------060408020006020600090206" X-Archive-Number: 200306/207 X-Sequence-Number: 13965 This is a multi-part message in MIME format. --------------060408020006020600090206 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, For not so big applications you could consider converting the binary image/file into text, using base64, then store the resulting text. For example I have an app. where each member may have one or two images on their account. So when the user upload's their image I base64 it and store the text. Then when we need to see the image select the text and decode it back to binary format. It work's well for me. This way only text is stored. It's also handy as you don't need to worry about file name's being the same. It will increase the file size by about 30%. Search the web for base64 example's, I'm sure you'll find examples to work with. You can email me off list if you like to see some PHP code which does this. Cheers Rudi. Jonathan Gardner wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On Tuesday 17 June 2003 02:00, cristi wrote: > > >>I want to insert a picture in a table from an internet browser using a >>script made in perl. >>Has somebody a code example with this kind a problem (I need only a code >>fragment)? >> >> >> > >Despite PostgreSQL's powerful BLOB features, I would strongly suggest against >storing these kind of things in the database. It is better to have it in a >local file for several reasons. > >1) Apache can server up local images lightning fast >2) You can edit local images with your favorite image editor (ie, Gimp, >Photoshop) >3) You can ftp, scp, sftp the image around without a problem. >4) You can tar it up and archive it. >5) You can move it off of your burdened PostgreSQL database server machine and >on to its own image server when your site becomes popular. > >While all of the above are certainly possible with PostgreSQL, it is a bit >more complicated. > >And remember, while your database server is small now, it will grow, and grow, >and grow, and grow. It will one day become the bottleneck in your operations. >That is an inevitable fact of any dynamic website. > >- -- >Jonathan Gardner >(was jgardn@alumni.washington.edu) >Live Free, Use Linux! >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.2.1 (GNU/Linux) > >iD8DBQE+7yYTWgwF3QvpWNwRAv3WAKDFrjfQUpQFmZFvVMismUeoxABoDQCfY/F7 >LajclhvacQOgsn+6qnLEEwQ= >=k0vW >-----END PGP SIGNATURE----- > >---------------------------(end of broadcast)--------------------------- >TIP 8: explain analyze is your friend > > > --------------060408020006020600090206 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi,

For not so big applications you could consider converting the binary image/file into text, using base64, then store the resulting text.
For example I have an app. where each member may have one or two images on their account.
So when the user upload's their image I base64 it and store the text.
Then when we need to see the image select the text and decode it back to binary format.

It work's well for me.
This way only text is stored. It's also handy as you don't need to worry about file name's being the same.
It will increase the file size by about 30%.

Search the web for base64 example's, I'm sure you'll find examples to work with.
You can email me off list if you like to see some PHP code which does this.

Cheers
Rudi.




Jonathan Gardner wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 17 June 2003 02:00, cristi wrote:
  
I want to insert a picture in a table from an internet browser using a
script made in perl.
Has somebody a code example with this kind a problem (I need only a code
fragment)?

    

Despite PostgreSQL's powerful BLOB features, I would strongly suggest against 
storing these kind of things in the database. It is better to have it in a 
local file for several reasons.

1) Apache can server up local images lightning fast
2) You can edit local images with your favorite image editor (ie, Gimp, 
Photoshop)
3) You can ftp, scp, sftp the image around without a problem.
4) You can tar it up and archive it.
5) You can move it off of your burdened PostgreSQL database server machine and 
on to its own image server when your site becomes popular.

While all of the above are certainly possible with PostgreSQL, it is a bit 
more complicated.

And remember, while your database server is small now, it will grow, and grow, 
and grow, and grow. It will one day become the bottleneck in your operations. 
That is an inevitable fact of any dynamic website.

- -- 
Jonathan Gardner <jgardner@jonathangardner.net>
(was jgardn@alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+7yYTWgwF3QvpWNwRAv3WAKDFrjfQUpQFmZFvVMismUeoxABoDQCfY/F7
LajclhvacQOgsn+6qnLEEwQ=
=k0vW
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

  

--------------060408020006020600090206--