473,624 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADODB.Stream 'format error: not a pdf or corrupt' only on large file

I use the code below to authorise the download of certain files.
Thus, instead of linking to the file in a wwwroot directory, I link to
this code with the filename as a parameter, and the script streams the
file if the user is authorised.

This has worked fine on PDFs, DOCs, XLS, etc. until today, and 18MB
file presents the error message 'format error: not a pdf or corrupt'.

Is there a file size limit, or a default that needs overridden? Any
thoughts?

Cheers.
The Code:

<%@ language="javas cript"%>
<%
if (Session("UserI D") == 0) {
Response.Redire ct("notauthoriz ed.asp");
} else {
Response.Conten tType = "applicatio n/x-unknown";
var fn = Request.QuerySt ring("fn");
// Response.Write( fn);
// Response.End();
// fn = "ecpa_efficacy_ minutes_08_11_0 6.pdf"
var FPath = "E:\\Inetpub\\i rac-online.org\\doc uments\\" + fn;
Response.AddHea der("Content-Disposition","a ttachment; filename=" +
fn);

var adoStream = Server.CreateOb ject("ADODB.Str eam");
adoStream.Open( );
adoStream.Type = 1;
adoStream.LoadF romFile(FPath);
Response.Binary Write(adoStream .Read());
adoStream.Close ();
adoStream = null;

Response.End();
}
%>

Mar 29 '07 #1
7 9878
iporter wrote:
I use the code below to authorise the download of certain files.
Thus, instead of linking to the file in a wwwroot directory, I link to
this code with the filename as a parameter, and the script streams the
file if the user is authorised.

This has worked fine on PDFs, DOCs, XLS, etc. until today, and 18MB
file presents the error message 'format error: not a pdf or corrupt'.
What do you mean by "presents the error message"? Is this a client-side
error or a server-side error?

If client-side, then you may need to examine things like your ASP output
buffer size and your script timeouts.

More than likely, you can solve this by writing in chunks. See the example
about halfway down this article:
http://www.aspfaq.com/show.asp?id=2161

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Mar 29 '07 #2
On Mar 29, 7:46 pm, "Dave Anderson" <NYRUMTPEL...@s pammotel.com>
wrote:
iporter wrote:
I use the code below to authorise the download of certain files.
Thus, instead of linking to the file in a wwwroot directory, I link to
this code with the filename as a parameter, and the script streams the
file if the user is authorised.
This has worked fine on PDFs, DOCs, XLS, etc. until today, and 18MB
file presents the error message 'format error: not a pdf or corrupt'.

What do you mean by "presents the error message"? Is this a client-side
error or a server-side error?

If client-side, then you may need to examine things like your ASP output
buffer size and your script timeouts.

More than likely, you can solve this by writing in chunks. See the example
about halfway down this article:http://www.aspfaq.com/show.asp?id=2161

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Cheers - resolution involved increasing the AspBufferingLim it in
Metabase.xml - see http://clearglass.net/index.php?p=10.

Mar 30 '07 #3

"iporter" <is******@gmail .comwrote in message
news:11******** **************@ o5g2000hsb.goog legroups.com...
On Mar 29, 7:46 pm, "Dave Anderson" <NYRUMTPEL...@s pammotel.com>
wrote:
iporter wrote:
I use the code below to authorise the download of certain files.
Thus, instead of linking to the file in a wwwroot directory, I link to
this code with the filename as a parameter, and the script streams the
file if the user is authorised.
This has worked fine on PDFs, DOCs, XLS, etc. until today, and 18MB
file presents the error message 'format error: not a pdf or corrupt'.
What do you mean by "presents the error message"? Is this a client-side
error or a server-side error?

If client-side, then you may need to examine things like your ASP output
buffer size and your script timeouts.

More than likely, you can solve this by writing in chunks. See the
example
about halfway down this article:http://www.aspfaq.com/show.asp?id=2161

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use
of this email address implies consent to these terms.

Cheers - resolution involved increasing the AspBufferingLim it in
Metabase.xml - see http://clearglass.net/index.php?p=10.
Here is a port of my VBScript SendFileToRespo nse function (I haven't tested
this JScript version):-

function SendFileToRespo nse(FilePath, FileName)
{
var clChunkSize = 1048576 // 1MB

Response.Buffer = false

Response.Conten tType = "applicatio n/octet-stream"
Response.AddHea der("Content-Disposition",
"attachment ; Filename=" + FileName)

var oStream = Server.CreateOb ject("ADODB.Str eam")
oStream.Type = 1 // Binary
oStream.Open()
oStream.LoadFro mFile(FilePath)

for (var i = 1, length = Math.floor(oStr eam.Size / clChunkSize); i <=
length; i++)
Response.Binary Write(oStream.R ead(clChunkSize ))

if ((oStream.Size % clChunkSize) <0)
Response.Binary Write(oStream.R ead(oStream.Siz e % clChunkSize))
oStream.Close()
}

It has the advantage of using memory more effeciently on the server by
turning off buffering and chunking the file to the response. There is no
need to modify the buffering limit from the default 4MB when using this
function.

Mar 30 '07 #4
"Anthony Jones" wrote:
It has the advantage of using memory more effeciently on
the server by turning off buffering and chunking the file
to the response.
Is that fact or speculation? I've never seen evidence that this is more
efficient on the server.

There is no need to modify the buffering limit from the
default 4MB when using this function.
Agreed. And this one is undeniable.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Mar 30 '07 #5

"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:13******** *****@corp.supe rnews.com...
"Anthony Jones" wrote:
It has the advantage of using memory more effeciently on
the server by turning off buffering and chunking the file
to the response.

Is that fact or speculation? I've never seen evidence that this is more
efficient on the server.
It's not a fact by observation but neither is it speculation.

Here is a fact:-

Response.Binary Write doesn't return until all the buffer contents have been
sent.

I'll let you do the math.

Mar 30 '07 #6
Anthony Jones wrote:
It's not a fact by observation but neither is it speculation.

Response.Binary Write doesn't return until all the buffer
contents have been sent.
Doesn't return what? From what? To what? This does not make any sense to me.

I'll let you do the math.
OK. In either case, the same amount of content has to be put into the
buffer, and the same amount written from the buffer. You don't even bother
to speculate about the cost of repeatedly using Stream.Read(byt es) over
Stream.Read(adR eadAll). So absent the Urim and Thummim neccessary for
scrying the Response Object, there does not seem to be any "math" to do. You
are *clearly* speculating.

I will grant this -- when combined with Response.isClie ntConnected [1],
using the chunked method allows you to abort the process before the entire
Stream is dealt with, which seems at first glance like a decent idea for
sending very large files. But since your example ignores isClientConnect ed,
you have not made any sort of "performanc e" case whatsoever.

[1] Is it a method or a property? The documentation calls it a property, buy
shows it as a method. Stranger still, you can treat it as either one in
JScript.
http://msdn.microsoft.com/library/en...9548d3f8b0.asp

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Mar 30 '07 #7

"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
Anthony Jones wrote:
It's not a fact by observation but neither is it speculation.

Response.Binary Write doesn't return until all the buffer
contents have been sent.

Doesn't return what? From what? To what? This does not make any sense to
me.
>
I'll let you do the math.

OK. In either case, the same amount of content has to be put into the
buffer, and the same amount written from the buffer. You don't even bother
to speculate about the cost of repeatedly using Stream.Read(byt es) over
Stream.Read(adR eadAll). So absent the Urim and Thummim neccessary for
scrying the Response Object, there does not seem to be any "math" to do.
You
are *clearly* speculating.

I will grant this -- when combined with Response.isClie ntConnected [1],
using the chunked method allows you to abort the process before the entire
Stream is dealt with, which seems at first glance like a decent idea for
sending very large files. But since your example ignores
isClientConnect ed,
you have not made any sort of "performanc e" case whatsoever.
Dave,

My apologies I've seem to have managed to irk you once again.

What I meant by 'sent' is sent and acknowledged by the client.

With a buffered response the entire contents is duplicated in memory at the
same time, once in the array read from the stream and once in the buffer.
How much of the file is also duplicated inside the stream object I'm not
certain possibly all of it.

With the 'unbuffered' response only 1MB of the file is duplicated in memory
at the time plus whatever is in the ADODB stream.

Of course in the buffered solution the stream and the array are released
when the client starts to receive bytes. At this time the script context
will also be torn down. Ultimately the average memory requirement for the
buffered solution is likely to be less than my unbuffered one. This would
depend on details of the ADODB stream internals, how much the script context
uses and how big the file is. However it's peak memory requirements are
significantly more.

Another implementation detail that I don't known is whether IIS releases
some of the buffer whilst still using it. It seems an obvious thing to do
which would mean the buffered technique's average memory usage would be
somewhere approaching half the file size. The slower the link the closer to
half the file size it will be.

OTH the 'unbuffered' solution will keep the ADODB.Stream and therefore
potentially a duplicate of the file in memory for the duration of the send.
Hence it's peak requirement is at worst the file size + 2MB. However that is
also it's average requirement as well.

Overall then in a real world I'm probably wrong. Unless spike memory
requirement of the buffered solution is a problem. Although might I risk
your ire once again I do believe ADODB.Stream uses a .tmp file when mem
usage becomes excessive but I could be wrong ... again.

Anthony.


Mar 30 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2373
by: Mohit Gupta | last post by:
Hi all, I am using Microsoft Visual Interdev to write/develop ASP code. Refering to code below, when I tried to create object of class "ADODB.Stream", an error was reported by IIS/ASP error engine stating "invalid class Cod --------- set testObject = Server.CreateObject("ADODB.Stream" When I used 'testObject.' in Microsoft Visual Interdev software, all the related methods and variables were listed in front of me. This means that...
1
6183
by: JohnWayne | last post by:
Hello All, I am trying to use ADODB.Stream , to write a graphic to the asp page. However I cannot seem to send my byte Array to the objStream.Write (mybyteArray) Does anyone know how to convert the byte array to binary data that the Write method will accept ?? As it always returns: Error Type: "Microsoft VBScript runtime (0x800A000D)"
3
7854
by: Harry Hudini | last post by:
Hi, I have an asp page that needs to display the string that is returned from a cgi file. As an example, if you enter http://mydomain.com/mycgi.cgi?98127398 in to a browser, it will display YES or NO I need to have my asp code query this url, get the resulting string, then act upon it (basically use the answer to display a nice big tick or a big
1
5242
by: guyv | last post by:
Hello! I wanna read binary data from database with ADODB.Stream object. So I wrote code.. --------- <% query = "SELECT * FROM Categories" adoDB.DefaultDatabase = "Northwind"
3
9475
by: C | last post by:
Re: Microsoft Knowledge Base Article - 870669 How to disable the ADODB.Stream object from Internet Explorer You may recently have heard of the vulnarability exposed by Internet Explorer as described in that article: "An ADO stream object contains methods for reading and writing binary files and text files. When an ADO stream object is combined with known security vulnerabilities in Internet Explorer, a Web site could execute scripts...
4
9952
by: Fresh_Air_Rider | last post by:
Hi In the "good old" Classic ASP days, I used to stream records from a SQL Server database out to the user's browser in CSV format by using a combination of COALESCE and the ADODB.Stream object. The trouble is that I'm not really sure how to do this in C# 2005. This was a very useful technique and if anyone could please show me how to adapt the Classic ASP code to C# 2005, I'd be very grateful indeed.
5
2717
by: Mike | last post by:
We are intermittantly geting the following errors on our web site and they are always on and ADODB command of some sort. Any ideas? Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
10
19326
by: =?Utf-8?B?SnVhbg==?= | last post by:
Hi! I want to use ASP to download big files using ADODB.STREAM. It works very fine with files smaller than 80 MB. On the Webserver I can see that memory allocation and the process w3wp is running. After some time (more or less 2 minutes) I get a response timeout. Here is the code:
3
9218
gauravgmbhr
by: gauravgmbhr | last post by:
Hi All, I am trying to open a binary stream from a file and the creating a new stream from the opened stream and then trying to over wright the file and i am getting the following error ADODB.Stream error '800a0bbc' Write to file failed. /cops/RestartV1.asp, line 80
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.