Search Postgresql Archives

Re: Image storage questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux