Обсуждение: question about images

Поиск
Список
Период
Сортировка

question about images

От
Dag Gullberg
Дата:
Hi all,
    I have a problem with understanding how BLOB's
work in postgres. It seems as thoug I have to use

COPY BINARY table (imagefield) FROM 'absolutepath+imagename' ;

this ofcourse give the error

ERROR:  COPY BINARY: file signature not recognized

so I have new went througt some doc's and found that
some header has to be appended containing some info about
number of instances and flags etc.

NOW: Is there anyway I can deal with loading images from
files into my database from within a pgplsql function, or do I have
to hack some C code AND install c-functions as well, or even worse 8)
do some scripting outside the database.... ???

Thankfull for any input,

regards,
DagG





Re: question about images

От
Tom Lane
Дата:
Dag Gullberg <dag.gullberg@telia.com> writes:
>     I have a problem with understanding how BLOB's
> work in postgres. It seems as thoug I have to use
> COPY BINARY table (imagefield) FROM 'absolutepath+imagename' ;

No, what you want is lo_import().

            regards, tom lane

Re: question about images

От
Dag Gullberg
Дата:
Tom Lane <tgl@sss.pgh.pa.us> writes:

>Dag Gullberg <dag.gullberg@telia.com> writes:
>>        I have a problem with understanding how BLOB's
>> work in postgres. It seems as thoug I have to use
>> COPY BINARY table (imagefield) FROM 'absolutepath+imagename' ;
>
>
>No, what you want is lo_import().
>
>                        regards, tom lane
>

Thanks for the input - and you're right! And wrong!
I first thought of it as a neccessity to have the db to
render me all data in a ''select * from table where id=this_id;''
including image data. I had a problem with the fact that lo_export()
deposit the data on the local fs - anti-constructive if you are trying
to setup a highly distributed and scalable solution. So in that
context you were wrong! Or so I thought...

*But*, thinking about it - the solution is simple - use lo_import and
lo_export as you suggest - and deposit the outdata in a directory
available from a apache-server, serving only image transfers.

I don't know about performance yet, but it is doable -have tested that.


Voila - I'm done (?)

Thanks,

DagG


Re: question about images

От
Dag Gullberg
Дата:
torsdagen den 24 juli 2003 16:06 skrev Tom Lane:
> Dag Gullberg <dag.gullberg@telia.com> writes:
> >     I have a problem with understanding how BLOB's
> > work in postgres. It seems as thoug I have to use
> > COPY BINARY table (imagefield) FROM 'absolutepath+imagename' ;
>
> No, what you want is lo_import().
>
>             regards, tom lane

Wanting to share the novice discovery of things that is well
known to you buffs I now can say that my problems are very neatly
solved by using the pgsql module in php (type lo_import() access).

Anybody out there have a similar problem the postgres JDBC doc
may help if you are going in that direction. If php and "native"
postgress access is wanted, see (e.g.)

 http://se.php.net/manual/en/function.pg-lo-create.php

All in a box, as it were .....

DagG