Fw: working with blobs in a two-server setup

Fw: working with blobs in a two-server setup

am 27.10.2004 19:25:43 von Thom Dyson

Without a code sample it is pretty hard to offer any specific advice about
what you are doing wrong.

Here is what I used to load some files. All the $file____ variables are
set above this block.

$localname = "/home/tdyson/" . $filename;
$fp = fopen($localname,"r");
$buffer = fread($fp,filesize($localname));
fclose($fp);
$conn = pg_connect("host=myhost.sybex.com port=5432 dbname=my_db
user=my_name password=my_password ");
pg_query ($conn, "begin");
$oid = pg_lo_create ($conn);

$rs = pg_exec($conn,"insert into download_links (file_size,
file_name, file_date, product_id, file_version, the_file)
values('" . $filesize . "','" . $filename . "','"
..$filedate . "','" . $product_id . "','" . $fileversion . "','" . $oid .
"')"); // the_file field type must be "oid"

$handle = pg_lo_open ($conn, $oid, "w");

pg_lo_write ($handle, $buffer);
pg_lo_close ($handle);
pg_query ($conn, "commit");
pg_close();


Thom Dyson
Director of Information Services
Sybex, Inc.



pgsql-php-owner@postgresql.org wrote on 10/27/2004 12:42:34 AM:

> Hi everyone,

> I have a two server setup (both debian stable) with apache and the
> PHP engine on server1 and postgresql on server2. My application
> should be able to store BLOBs in the database. In a test environment
> where everything was running on a single server it was OK (I used
> the ADBOdb lo functions there) but now I get into all sorts of
> trouble: the database can't find the uploaded file, which makes
> sense: it's in /tmp on server1! :-(

> Does anyone know how I can handle this or have a pointer to a howto?

> Thanks!

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

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

Re: Fw: working with blobs in a two-server setup

am 27.10.2004 22:28:05 von Jules Alberts

Thom Dyson zei:
> Without a code sample it is pretty hard to offer any specific advice
> about
> what you are doing wrong.
>
> Here is what I used to load some files. All the $file____ variables
> are
> set above this block.
>
> $localname =3D "/home/tdyson/" . $filename;
> $fp =3D fopen($localname,"r");
^^^^^

Thanks for reacting Tom. Seems that the problem was somewhere in the
adodb code. I switched to the native pg functions and they work
fine, so my problems are solved. Looking back i'm not sure if the
change to a two server setup was the problem... The test server was
a Fedora Core 2, now it's two Debian stables which have no doubt
older versions of adodb (and every other package, but that's the
price for stability I guess :)

Anyway, it's working now, thanks again.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings