Retrieving Oracle BLOB

Discussion in 'ASP .Net' started by Peter Afonin, Jul 25, 2006.

  1. Peter Afonin

    Peter Afonin Guest

    Hello,

    I have Word documents stored in the Oracle database in the BLOB field
    that I need to retrieve. I've found the way of doing it:

    While dr.Read


    sName = dr("TE_PM_ATTACH_NAME")
    bLob = dr.GetOracleLob(1)
    Response.AppendHeader("Content-type:",
    "application/force-download")
    Response.AppendHeader("Content-Disposition", "attachment;
    filename=" & sName)
    Response.AppendHeader("Content-Length", bLob.Length)
    Response.Charset = "UTF-8"
    ' write the blob data - this will begin to force the
    download
    Response.BinaryWrite(bLob.Value)

    End While

    The only problem here is that when the customer is trying to open the
    document, in most cases (but not always, which is weird) he gets
    message like this:

    This file could not be found.
    Try one or more of the following:
    * Check the spelling of the name of the document.
    * Try a different file name.
    (C:\...\Accessing BLOB data 2[1].doc)

    So he can only download this document.

    If it's an image file instead of word document - there are no problems.

    I would appreciate any suggestions on how to deal with this.

    Thank you,

    Peter
     
    Peter Afonin, Jul 25, 2006
    #1
    1. Advertising

  2. Peter Afonin

    Mischa Kroon Guest

    > The only problem here is that when the customer is trying to open the
    > document, in most cases (but not always, which is weird) he gets
    > message like this:
    >
    > This file could not be found.
    > Try one or more of the following:
    > * Check the spelling of the name of the document.
    > * Try a different file name.
    > (C:\...\Accessing BLOB data 2[1].doc)


    I think the problem lies here:
    Response.AppendHeader("Content-type:", "application/force-download")

    For word this should be:

    "application/vnd.ms-word"

    A bit more information can be found here:
    http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html
     
    Mischa Kroon, Jul 26, 2006
    #2
    1. Advertising

  3. Peter Afonin

    Peter Afonin Guest

    Thank you very much, Mischa, I'll try this.

    Peter

    "Mischa Kroon" <> wrote in message
    news:55a53$44c6a281$3ec3ac38$...
    >> The only problem here is that when the customer is trying to open the
    >> document, in most cases (but not always, which is weird) he gets
    >> message like this:
    >>
    >> This file could not be found.
    >> Try one or more of the following:
    >> * Check the spelling of the name of the document.
    >> * Try a different file name.
    >> (C:\...\Accessing BLOB data 2[1].doc)

    >
    > I think the problem lies here:
    > Response.AppendHeader("Content-type:", "application/force-download")
    >
    > For word this should be:
    >
    > "application/vnd.ms-word"
    >
    > A bit more information can be found here:
    > http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html
    >
    >
    >
     
    Peter Afonin, Jul 26, 2006
    #3
  4. Peter Afonin

    Peter Afonin Guest

    Didn't work, unfortunately. It seems to be a problem with the local
    caching, but I don't know what exactly.

    Mischa Kroon wrote:
    > > The only problem here is that when the customer is trying to open the
    > > document, in most cases (but not always, which is weird) he gets
    > > message like this:
    > >
    > > This file could not be found.
    > > Try one or more of the following:
    > > * Check the spelling of the name of the document.
    > > * Try a different file name.
    > > (C:\...\Accessing BLOB data 2[1].doc)

    >
    > I think the problem lies here:
    > Response.AppendHeader("Content-type:", "application/force-download")
    >
    > For word this should be:
    >
    > "application/vnd.ms-word"
    >
    > A bit more information can be found here:
    > http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html
     
    Peter Afonin, Jul 26, 2006
    #4
  5. Peter Afonin

    Peter Afonin Guest

    I'm thinking maybe I should add custom headers in IIS. Not sure what is
    required...

    Mischa Kroon wrote:
    > > The only problem here is that when the customer is trying to open the
    > > document, in most cases (but not always, which is weird) he gets
    > > message like this:
    > >
    > > This file could not be found.
    > > Try one or more of the following:
    > > * Check the spelling of the name of the document.
    > > * Try a different file name.
    > > (C:\...\Accessing BLOB data 2[1].doc)

    >
    > I think the problem lies here:
    > Response.AppendHeader("Content-type:", "application/force-download")
    >
    > For word this should be:
    >
    > "application/vnd.ms-word"
    >
    > A bit more information can be found here:
    > http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html
     
    Peter Afonin, Jul 26, 2006
    #5
  6. Peter Afonin

    Mischa Kroon Guest

    "Peter Afonin" <> wrote in message
    news:...
    > Didn't work, unfortunately. It seems to be a problem with the local
    > caching, but I don't know what exactly.


    Are you giving the downloads distinct filenames ?
    If not you might want to try this.
     
    Mischa Kroon, Jul 26, 2006
    #6
  7. Is this an SSL connection? If so, and you are using IE, if the "Save
    Encrypted files to disk" is disabled then IE will not be able to put a copy
    of the file in "Temporary Internet Files".
    --
    Brad

    "Software is like melted pudding..."


    "Peter Afonin" wrote:

    > I'm thinking maybe I should add custom headers in IIS. Not sure what is
    > required...
    >
    > Mischa Kroon wrote:
    > > > The only problem here is that when the customer is trying to open the
    > > > document, in most cases (but not always, which is weird) he gets
    > > > message like this:
    > > >
    > > > This file could not be found.
    > > > Try one or more of the following:
    > > > * Check the spelling of the name of the document.
    > > > * Try a different file name.
    > > > (C:\...\Accessing BLOB data 2[1].doc)

    > >
    > > I think the problem lies here:
    > > Response.AppendHeader("Content-type:", "application/force-download")
    > >
    > > For word this should be:
    > >
    > > "application/vnd.ms-word"
    > >
    > > A bit more information can be found here:
    > > http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html

    >
    >
     
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=, Jul 26, 2006
    #7
  8. Peter Afonin

    Peter Afonin Guest

    Hi Mischa,

    How would I do this? No, I don't. I store the name of the original file
    in a separate field, and then just call the row id to retrieve this
    file from the BLOB field.

    Peter

    Mischa Kroon wrote:
    > "Peter Afonin" <> wrote in message
    > news:...
    > > Didn't work, unfortunately. It seems to be a problem with the local
    > > caching, but I don't know what exactly.

    >
    > Are you giving the downloads distinct filenames ?
    > If not you might want to try this.
     
    Peter Afonin, Jul 26, 2006
    #8
  9. Peter Afonin

    Peter Afonin Guest

    Thank you, Brad.

    No, this is just our Intranet, no SSL.

    Peter

    Brad Roberts wrote:
    > Is this an SSL connection? If so, and you are using IE, if the "Save
    > Encrypted files to disk" is disabled then IE will not be able to put a copy
    > of the file in "Temporary Internet Files".
    > --
    > Brad
    >
    > "Software is like melted pudding..."
    >
    >
    > "Peter Afonin" wrote:
    >
    > > I'm thinking maybe I should add custom headers in IIS. Not sure what is
    > > required...
    > >
    > > Mischa Kroon wrote:
    > > > > The only problem here is that when the customer is trying to open the
    > > > > document, in most cases (but not always, which is weird) he gets
    > > > > message like this:
    > > > >
    > > > > This file could not be found.
    > > > > Try one or more of the following:
    > > > > * Check the spelling of the name of the document.
    > > > > * Try a different file name.
    > > > > (C:\...\Accessing BLOB data 2[1].doc)
    > > >
    > > > I think the problem lies here:
    > > > Response.AppendHeader("Content-type:", "application/force-download")
    > > >
    > > > For word this should be:
    > > >
    > > > "application/vnd.ms-word"
    > > >
    > > > A bit more information can be found here:
    > > > http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html

    > >
    > >
     
    Peter Afonin, Jul 26, 2006
    #9
  10. Peter Afonin

    Mischa Kroon Guest

    "Peter Afonin" <> wrote in message
    news:...
    > Hi Mischa,
    >
    > How would I do this? No, I don't. I store the name of the original file
    > in a separate field, and then just call the row id to retrieve this
    > file from the BLOB field.



    You might want to start doing this, otherwise you could use a guid or the id
    of the database table:

    xxx0123.doc or something.
     
    Mischa Kroon, Jul 27, 2006
    #10
  11. Peter Afonin

    Peter Afonin Guest

    Thank you, I'll try.

    Peter

    Mischa Kroon wrote:
    > "Peter Afonin" <> wrote in message
    > news:...
    > > Hi Mischa,
    > >
    > > How would I do this? No, I don't. I store the name of the original file
    > > in a separate field, and then just call the row id to retrieve this
    > > file from the BLOB field.

    >
    >
    > You might want to start doing this, otherwise you could use a guid or the id
    > of the database table:
    >
    > xxx0123.doc or something.
     
    Peter Afonin, Jul 27, 2006
    #11
  12. Peter Afonin

    Peter Afonin Guest

    This didn't work for me, but I've found the problem!

    I was missing this line at the end:

    Response.End()

    As soon as I added it - everything started to work as expected.

    Thank you for all you suggestions.

    Peter

    Mischa Kroon wrote:
    > "Peter Afonin" <> wrote in message
    > news:...
    > > Hi Mischa,
    > >
    > > How would I do this? No, I don't. I store the name of the original file
    > > in a separate field, and then just call the row id to retrieve this
    > > file from the BLOB field.

    >
    >
    > You might want to start doing this, otherwise you could use a guid or the id
    > of the database table:
    >
    > xxx0123.doc or something.
     
    Peter Afonin, Jul 27, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Vabo

    .NET and Oracle BLOB

    Robert Vabo, Aug 20, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    6,073
    Mark Kamoski
    Aug 27, 2003
  2. nkunapa
    Replies:
    4
    Views:
    6,766
    nkunapa
    Aug 10, 2005
  3. gbattine
    Replies:
    9
    Views:
    607
    Moiristo
    Jun 29, 2006
  4. Replies:
    9
    Views:
    638
  5. Feyruz
    Replies:
    4
    Views:
    2,338
    Sherm Pendley
    Oct 14, 2005
Loading...

Share This Page