Thread: Insert images through ASP

Insert images through ASP

From
"Dylan Milks"
Date:
I'm just wondering if anyone has ever inserted images into a Postgres DB through ASP. If so, could you please give me a snippet of code to show me how to do it. I can't seem to get it working.
 
Thanks,
- Dylan Milks


This communication, including its attachments, if any, is intended solely for the recipient; it is confidential and may contain personal or private information, or proprietary and/or privileged material. As such, any unauthorized use, retention, copying, disclosure or other distribution of this communication, or the taking of any action in reliance on its contents
is strictly prohibited. If you have received this communication in error, please notify us immediately and delete this communication (and any attachments.)

 

Re: Insert images through ASP

From
mike g
Date:
Hi,

I think you will need to be more specific to what scripting language you
are attempting to use, which blob data type is being used in the db(lo
or bytea), and possibly the database driver used (odbc / .net)
to get a response from the community.

Mike
On Fri, 2004-07-16 at 08:21, Dylan Milks wrote:
> I'm just wondering if anyone has ever inserted images into a Postgres
> DB through ASP. If so, could you please give me a snippet of code to
> show me how to do it. I can't seem to get it working.
>
> Thanks,
> - Dylan Milks
>
>
> ______________________________________________________________________
> This communication, including its attachments, if any, is intended
> solely for the recipient; it is confidential and may contain personal
> or private information, or proprietary and/or privileged material. As
> such, any unauthorized use, retention, copying, disclosure or other
> distribution of this communication, or the taking of any action in
> reliance on its contents
> is strictly prohibited. If you have received this communication in
> error, please notify us immediately and delete this communication (and
> any attachments.)
>
>
>

Re: Insert images through ASP

From
"Dylan Milks"
Date:
I'm using VB Script (ASP), ODBC and preferably I'd like to use the BYTEA field. I can get it to work using an OID data
type,but I'd like to see about BYTEA.
 
 
I'm using Postgres 7.3
 
Thanks in advance.
 
- Dylan

    -----Original Message----- 
    From: mike g [mailto:mike@thegodshalls.com] 
    Sent: Fri 7/16/2004 11:07 PM 
    To: Dylan Milks 
    Cc: PostgreSQL (E-mail) 
    Subject: Re: [GENERAL] Insert images through ASP
    
    

    Hi,
    
    I think you will need to be more specific to what scripting language you
    are attempting to use, which blob data type is being used in the db(lo
    or bytea), and possibly the database driver used (odbc / .net)
    to get a response from the community.
    
    Mike
    On Fri, 2004-07-16 at 08:21, Dylan Milks wrote:
    > I'm just wondering if anyone has ever inserted images into a Postgres
    > DB through ASP. If so, could you please give me a snippet of code to
    > show me how to do it. I can't seem to get it working.
    > 
    > Thanks,
    > - Dylan Milks
    >
    >
    > ______________________________________________________________________
    > This communication, including its attachments, if any, is intended
    > solely for the recipient; it is confidential and may contain personal
    > or private information, or proprietary and/or privileged material. As
    > such, any unauthorized use, retention, copying, disclosure or other
    > distribution of this communication, or the taking of any action in
    > reliance on its contents
    > is strictly prohibited. If you have received this communication in
    > error, please notify us immediately and delete this communication (and
    > any attachments.)
    >
    > 
    >
    
    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend
    
    


Re: Insert images through ASP

From
"Dylan Milks"
Date:
I'm using VB Script (ASP), ODBC and preferably I'd like to use the BYTEA field. I can get it to work using an OID data
type,but I'd like to see about BYTEA.
 

I'm using Postgres 7.3

Thanks in advance.

- Dylan

        -----Original Message-----
        From: mike g [mailto:mike@thegodshalls.com]
        Sent: Fri 7/16/2004 11:07 PM
        To: Dylan Milks
        Cc: PostgreSQL (E-mail)
        Subject: Re: [GENERAL] Insert images through ASP
       
       

        Hi,
       
        I think you will need to be more specific to what scripting language you
        are attempting to use, which blob data type is being used in the db(lo
        or bytea), and possibly the database driver used (odbc / .net)
        to get a response from the community.
       
        Mike
        On Fri, 2004-07-16 at 08:21, Dylan Milks wrote:
        > I'm just wondering if anyone has ever inserted images into a Postgres
        > DB through ASP. If so, could you please give me a snippet of code to
        > show me how to do it. I can't seem to get it working.
        >
        > Thanks,
        > - Dylan Milks
        >
        >
        > ______________________________________________________________________
        > This communication, including its attachments, if any, is intended
        > solely for the recipient; it is confidential and may contain personal
        > or private information, or proprietary and/or privileged material. As
        > such, any unauthorized use, retention, copying, disclosure or other
        > distribution of this communication, or the taking of any action in
        > reliance on its contents
        > is strictly prohibited. If you have received this communication in
        > error, please notify us immediately and delete this communication (and
        > any attachments.)
        >
        >
        >
       
        ---------------------------(end of broadcast)---------------------------
        TIP 8: explain analyze is your friend
       
       


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match


Re: Insert images through ASP

From
Mike G
Date:
Ok,
It is late and I am getting sleepy but..

create table large_obj
(
image name text,
the_image bytea
);

insert into large_obj values('the name','/home/auser/file.jpg');

above stores a file path to image.

I can't remember at the moment for sure but maybe removing the '' from around the /home/auser will actually store the
imagewithin the database instead of using the fileserver. 

There was a really good webpage explaining this that I bookmarked somewhere.  IF i could only remember which pc I was
on.....


HTH

 Tue, Jul 20, 2004 at 09:42:36PM -0500, Dylan Milks wrote:
> I'm using VB Script (ASP), ODBC and preferably I'd like to use the BYTEA field. I can get it to work using an OID
datatype, but I'd like to see about BYTEA. 
>
> I'm using Postgres 7.3
>
> Thanks in advance.
>
> - Dylan
>
>         -----Original Message-----
>         From: mike g [mailto:mike@thegodshalls.com]
>         Sent: Fri 7/16/2004 11:07 PM
>         To: Dylan Milks
>         Cc: PostgreSQL (E-mail)
>         Subject: Re: [GENERAL] Insert images through ASP
>
>
>
>         Hi,
>
>         I think you will need to be more specific to what scripting language you
>         are attempting to use, which blob data type is being used in the db(lo
>         or bytea), and possibly the database driver used (odbc / .net)
>         to get a response from the community.
>
>         Mike
>         On Fri, 2004-07-16 at 08:21, Dylan Milks wrote:
>         > I'm just wondering if anyone has ever inserted images into a Postgres
>         > DB through ASP. If so, could you please give me a snippet of code to
>         > show me how to do it. I can't seem to get it working.
>         >
>         > Thanks,
>         > - Dylan Milks
>         >
>         >
>         > ______________________________________________________________________
>         > This communication, including its attachments, if any, is intended
>         > solely for the recipient; it is confidential and may contain personal
>         > or private information, or proprietary and/or privileged material. As
>         > such, any unauthorized use, retention, copying, disclosure or other
>         > distribution of this communication, or the taking of any action in
>         > reliance on its contents
>         > is strictly prohibited. If you have received this communication in
>         > error, please notify us immediately and delete this communication (and
>         > any attachments.)
>         >
>         >
>         >
>
>         ---------------------------(end of broadcast)---------------------------
>         TIP 8: explain analyze is your friend
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Re: Insert images through ASP

From
"Dylan Milks"
Date:
Thanks for trying. However, the code you gave will only work if the image field is a OID, not BYTEA. With BYTEA I would
haveto convert the image to a byte stream, then insert. Also, the file path in your example assumes the image is on a
UNIX/LINUX/whateverbox. It won't work if the image is on a Windows machine, i.e.:  

insert into img_table values('image name', 'C:/WINNT/Web/Wallpaper/SL600_1.jpg');
OR
insert into img_table values('image name', C:/WINNT/Web/Wallpaper/SL600_1.jpg);

It doesn't like the colon (:) and slashes (/)

What I want to do is upload an image from an ASP page and insert it into a table. I don't want to store the image on
thefile system, even if it's only temporary. 

- Dylan


-----Original Message-----
From: Mike G [mailto:mike@thegodshalls.com]
Sent: Wednesday, July 21, 2004 1:25 AM
To: Dylan Milks
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Insert images through ASP


Ok,
It is late and I am getting sleepy but..

create table large_obj
(
image name text,
the_image bytea
);

insert into large_obj values('the name','/home/auser/file.jpg');

above stores a file path to image.

I can't remember at the moment for sure but maybe removing the '' from around the /home/auser will actually store the
imagewithin the database instead of using the fileserver. 

There was a really good webpage explaining this that I bookmarked somewhere.  IF i could only remember which pc I was
on.....


HTH

 Tue, Jul 20, 2004 at 09:42:36PM -0500, Dylan Milks wrote:
> I'm using VB Script (ASP), ODBC and preferably I'd like to use the BYTEA field. I can get it to work using an OID
datatype, but I'd like to see about BYTEA. 
>
> I'm using Postgres 7.3
>
> Thanks in advance.
>
> - Dylan
>
>         -----Original Message-----
>         From: mike g [mailto:mike@thegodshalls.com]
>         Sent: Fri 7/16/2004 11:07 PM
>         To: Dylan Milks
>         Cc: PostgreSQL (E-mail)
>         Subject: Re: [GENERAL] Insert images through ASP
>
>
>
>         Hi,
>
>         I think you will need to be more specific to what scripting language you
>         are attempting to use, which blob data type is being used in the db(lo
>         or bytea), and possibly the database driver used (odbc / .net)
>         to get a response from the community.
>
>         Mike
>         On Fri, 2004-07-16 at 08:21, Dylan Milks wrote:
>         > I'm just wondering if anyone has ever inserted images into a Postgres
>         > DB through ASP. If so, could you please give me a snippet of code to
>         > show me how to do it. I can't seem to get it working.
>         >
>         > Thanks,
>         > - Dylan Milks
>         >
>         >
>         > ______________________________________________________________________
>         > This communication, including its attachments, if any, is intended
>         > solely for the recipient; it is confidential and may contain personal
>         > or private information, or proprietary and/or privileged material. As
>         > such, any unauthorized use, retention, copying, disclosure or other
>         > distribution of this communication, or the taking of any action in
>         > reliance on its contents
>         > is strictly prohibited. If you have received this communication in
>         > error, please notify us immediately and delete this communication (and
>         > any attachments.)
>         >
>         >
>         >
>
>         ---------------------------(end of broadcast)---------------------------
>         TIP 8: explain analyze is your friend
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Re: Insert images through ASP

From
Doug McNaught
Date:
"Dylan Milks" <DMilks@greenridge.ca> writes:

> What I want to do is upload an image from an ASP page and insert it
> into a table. I don't want to store the image on the file system,
> even if it's only temporary.

Well, if you want to use bytea, you'll need to load the whole image
into memory, bytea-encode it, and insert into the table.  There's no
way to "stream" a value into a bytea column.

-Doug