From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Kaloyan Iliev <news1(at)faith(dot)digsys(dot)bg> |
Cc: | Gibson <gibson(at)nexgenstudio(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Saving a jpg into Postgresql table |
Date: | 2006-08-25 17:17:34 |
Message-ID: | 1156526254.1347.37.camel@dogma.v10.wvs |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2006-08-25 at 10:10 +0300, Kaloyan Iliev wrote:
> >
> > I have a projects using ASP.NET (VB.net) where i upload a jpeg file
> > using a web form and then save the jpeg file into a table. I've
> > decided to use "Oid" instead of "Bytea" as i heard that "Oid" is more
> > memory efficient. So can anyone point me to a website or link where i
> > can see the VB.net or C# code that does the SQL insert of the jpeg
> > file into the "Oid" data type column and also how to do a SQL select
> > to retrieve and display the image on a web form? Thanks
>
> Hi,
> I have problem like yours and I solve it like that:
> I transform the jpeg to Base64 text and then store it into normal text
> field.
> It takes aproximately 25-30% more disk space but is much easier for me
> to operate with it.
> When I read the object from the database I decode it and I have the file
> in the original format.
>
Why not go a step further and do this:
(1) encode the image as base64
(2) insert into mytable(image) values(decode('<base64 encoding of
image>','base64'));
Then, to get it back:
(1) select encode(image,'base64') from mytable;
(2) decode the base64 into your image
That way, you can store it in a bytea field and not waste the space.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Randy How | 2006-08-25 17:34:49 | Re: FW: Serverlog 100GB |
Previous Message | Bob Pawley | 2006-08-25 16:35:21 | Inserting Data |