Fw: working with blobs in a two-server setup

From: Thom Dyson <TDyson(at)sybex(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Fw: working with blobs in a two-server setup
Date: 2004-10-27 17:25:43
Message-ID: OF4B93C0D6.375439BE-ON88256F3A.005FB75C-88256F3A.005FBE03@sybex.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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(at)postgresql(dot)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(at)postgresql(dot)org

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Jules Alberts 2004-10-27 20:28:05 Re: Fw: working with blobs in a two-server setup
Previous Message Justin Wyer 2004-10-27 07:50:03 Re: working with blobs in a two-server setup