Re: Image storage questions

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Image storage questions
Date: 2005-05-18 20:57:01
Message-ID: 428BAC1D.80508@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> I was following this:
>
> http://www.postgresql.org/files/documentation/books/aw_pgsql/node96.html
>
> "Because large objects use the local filesystem, users connecting
> over a network cannot use lo_import or lo_export()."
>
> Confirmed using psql.
>
> What api/language are you using? Is this possible to do through
> DBI? If you don't use lo_import/lo_export, how do you
> insert/retrieve images? Pointers to docs are welcomed!

I have done it via PHP and I can definately insert with perl remotely
(although I don't recall ever exporting):

Creates a new large object and returns the object-id. $mode is a
bit-mask describing different attributes of the new object. Use the
following con-
stants:

$dbh->{pg_INV_WRITE}
$dbh->{pg_INV_READ}

Upon failure it returns undef.

$lobj_fd = $dbh->func($lobjId, $mode, ’lo_open’);

Opens an existing large object and returns an
object-descriptor for use in subsequent lo_* calls. For the mode bits
see lo_create. Returns undef
upon failure. Note that 0 is a perfectly correct object
descriptor!

$nbytes = $dbh->func($lobj_fd, $buf, $len, ’lo_write’);

Writes $len bytes of $buf into the large object $lobj_fd.
Returns the number of bytes written and undef upon failure.

$nbytes = $dbh->func($lobj_fd, $buf, $len, ’lo_read’);

Reads $len bytes into $buf from large object $lobj_fd.
Returns the number of bytes read and undef upon failure.

$loc = $dbh->func($lobj_fd, $offset, $whence, ’lo_lseek’);

Change the current read or write location on the large
object $obj_id. Currently $whence can only be 0 (L_SET). Returns the
current location and
undef upon failure.

$loc = $dbh->func($lobj_fd, ’lo_tell’);

Returns the current read or write location on the large
object $lobj_fd and undef upon failure.

$lobj_fd = $dbh->func($lobj_fd, ’lo_close’);

Closes an existing large object. Returns true upon success
and false upon failure.

$lobj_fd = $dbh->func($lobj_fd, ’lo_unlink’);

Deletes an existing large object. Returns true upon success
and false upon failure.

$lobjId = $dbh->func($filename, ’lo_import’);

Imports a Unix file as large object and returns the object
id of the new object or undef upon failure.

$ret = $dbh->func($lobjId, $filename, ’lo_export’);

>
> Thanks,
> Ed

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2005-05-18 21:03:42 Re: Image storage questions
Previous Message Ed L. 2005-05-18 20:49:40 Re: Image storage questions

Browse pgsql-hackers by date

  From Date Subject
Next Message Ed L. 2005-05-18 21:03:42 Re: Image storage questions
Previous Message Ed L. 2005-05-18 20:49:40 Re: Image storage questions