Re: How to save a image file in a postgres data field.

Поиск
Список
Период
Сортировка
От richard terry
Тема Re: How to save a image file in a postgres data field.
Дата
Msg-id 200808311243.45145.rterry@gnumed.net
обсуждение исходный текст
Ответ на Re: How to save a image file in a postgres data field.  ("Obe, Regina" <robe.dnd@cityofboston.gov>)
Ответы Re: How to save a image file in a postgres data field.
Список pgsql-novice
On Fri, 29 Aug 2008 08:01:16 am Obe, Regina wrote:

I've done a bit of research/tried some got and got part of the way.

I can convert a picture to a string to save but when I try and insert it into
the database I get the following:


Query failed:ERROR: invalid byte sequence for encoding "UTF8":0x89 HINT: This
error can also happen if the byte sequence does not match the encoding
expected by the server, which is controlled  by "client_encoding"

One of the users from  the Sydney user group Sydpug answered and helped me in
part  but mentioned this:
=============================================
Hear your pain, this was all done on debian linux. binmode was a gotcha

I've done it with a bytea column like this

use DBI ;
use DBD::Pg qw(:pg_types); #Required for us to use the *bytea* column
=============================================

I can't interpet the last line which (admittedly in another language) he says
is needed to use the bytea type.

Any further help appreciated.

Richard


> You can do bytea (which stores the image as a bytearray) or Large Object
> support (lo) which stores the oid reference to the image and stores it in
> another table.
>
> What language are you using?  Check way at the bottom of this page gives an
> example of storing files in bytea using .NET ADO driver as well as using
> the LO (Large Object support).
>
> Even if its not the language you use, could provide you with some ideas.
>
> Bytea example Look for "Working with binary data and bytea datatype"
> For LO look for "Working with large object support" in the below link
> http://npgsql.projects.postgresql.org/docs/1.0/manual/UserManual.html
>
> Hope that helps,
> Regina
>
>
> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org on behalf of richard terry
> Sent: Thu 8/28/2008 5:26 PM
> To: 'PostgreSQL Novice'
> Subject: [NOVICE] How to save a image file in a postgres data field.
>
> I want to be able to save an image, say myimage.png, into the database, and
> having difficulty with understanding the postgres documentation.
>
> The nearest I can figure is that there is a field called bytea ?? is this
> the correct one.
>
> If so, I wondered if anyone could give me a simple line of sql code which
> would demonstrate how to do this.
>
> Regards and thanks in advance.
>
> Richard



В списке pgsql-novice по дате отправления:

Предыдущее
От: Dale Seaburg
Дата:
Сообщение: Re: Date Of Entry and Date Of Change
Следующее
От: Robert Wimmer
Дата:
Сообщение: Re: Date Of Entry and Date Of Change