Response.binaryWrite chunks of data

K

Katie

Hi,

I made a posting a while ago regarding doing a binarywrite of a large
file in chunks and got a lot of helpful responses. I was able to make
it work then. Unfortunately when the project is being tested its not
working and I am getting some weird results when testing. A month ago I
was able to stream a file of size 80Mb and it worked like a dream

Yesterday it would not work on the same file, but would stream smaller
files. The largest file i was able to stream yesterday was 55.5MB.
Today it wouldnot work with the 55.5MB file but only with a file of max
size of around 54.5MB. I can't seem to figure out what is causing this.
Because the code is the same. I actually get no error, with the file
size i mentioned i get a popup window within seconds for the file
download. But anything greater than that file size (max size as of
today 54.5) even if it is an MB more i get a blank screen but it never
pop ups the file download box

I am attaching my code below for reference, here is the main part of
what I am doing

Set BinaryStream = CreateObject("ADODB.Stream")
set fs = Server.CreateObject("Scripting.FileSystemObject")
Set Fil = fs.GetFile(path & filename)
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.LoadFromFile Fil.path
Dim i

Const BlockSize = 1000
For i = 1 To BinaryStream.Size Step BlockSize
Response.BinaryWrite BinaryStream.Read(BlockSize)
Next
'f Not BinaryStream.EOS Then Response.BinaryWrite
BinaryStream.Read

Any help on this crazy stuff would be appreciated :)
Thanks :)
 
A

Anthony Jones

Katie said:
Hi,

I made a posting a while ago regarding doing a binarywrite of a large
file in chunks and got a lot of helpful responses. I was able to make
it work then. Unfortunately when the project is being tested its not
working and I am getting some weird results when testing. A month ago I
was able to stream a file of size 80Mb and it worked like a dream

Yesterday it would not work on the same file, but would stream smaller
files. The largest file i was able to stream yesterday was 55.5MB.
Today it wouldnot work with the 55.5MB file but only with a file of max
size of around 54.5MB. I can't seem to figure out what is causing this.
Because the code is the same. I actually get no error, with the file
size i mentioned i get a popup window within seconds for the file
download. But anything greater than that file size (max size as of
today 54.5) even if it is an MB more i get a blank screen but it never
pop ups the file download box

I am attaching my code below for reference, here is the main part of
what I am doing

Set BinaryStream = CreateObject("ADODB.Stream")
set fs = Server.CreateObject("Scripting.FileSystemObject")
Set Fil = fs.GetFile(path & filename)
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.LoadFromFile Fil.path
Dim i

Const BlockSize = 1000
For i = 1 To BinaryStream.Size Step BlockSize
Response.BinaryWrite BinaryStream.Read(BlockSize)
Next
'f Not BinaryStream.EOS Then Response.BinaryWrite
BinaryStream.Read

Any help on this crazy stuff would be appreciated :)
Thanks :)

I take it you have a Response.Buffer = False in there somewhere?
Also a block size of 1000 is way too small use a 1MB chunk instead.
 
E

Egbert Nierop \(MVP for IIS\)

Katie said:
Hi,

I made a posting a while ago regarding doing a binarywrite of a large
file in chunks and got a lot of helpful responses. I was able to make
it work then. Unfortunately when the project is being tested its not
working and I am getting some weird results when testing. A month ago I
was able to stream a file of size 80Mb and it worked like a dream


This is what you need :)

Response.ContentType = "application/x-zip-compressed" 'here your content -
type

Dim strFilePath, lSize, lBlocks
Const CHUNK = 2048
strFilePath = ["yourpath here!"]
set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile strFilePath
lSize = objStream.Size
Response.AddHeader "Content-Length", lSize
lBlocks = 1
Response.Buffer = False
Do Until objStream.EOS Or Not Response.IsClientConnected
Response.BinaryWrite(objStream.Read(CHUNK))
Loop

objStream.Close
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top