Retrieving Oracle BLOB

  • Thread starter Thread starter Peter Afonin
  • Start date Start date
P

Peter Afonin

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
 
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
 
Thank you very much, Mischa, I'll try this.

Peter

Mischa Kroon said:
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
 
Didn't work, unfortunately. It seems to be a problem with the local
caching, but I don't know what exactly.

Mischa said:
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
 
I'm thinking maybe I should add custom headers in IIS. Not sure what is
required...

Mischa said:
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 said:
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.
 
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 said:
I'm thinking maybe I should add custom headers in IIS. Not sure what is
required...

Mischa said:
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
 
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
 
Thank you, Brad.

No, this is just our Intranet, no SSL.

Peter

Brad said:
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 said:
I'm thinking maybe I should add custom headers in IIS. Not sure what is
required...

Mischa said:
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 said:
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.
 
Thank you, I'll try.

Peter

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

xxx0123.doc or something.
 
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
 
Back
Top