Home > Archive > ASP > October 2006 > Response.binaryWrite chunks of data
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Response.binaryWrite chunks of data
|
|
|
| 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 :)
| |
| Jon Paal 2006-10-30, 6:58 pm |
| I don't have sample code, but if the remainder of the file size is not equal to your block size it may not finish downloading. Test
for remainder size then reset block size to capture that last amount.
you will need to google for sample code it's been done many times.
"Katie" <DnkyCartRcr@gmail.com> wrote in message news:1161271398.418064.128390@h48g2000cwc.googlegroups.com...
> 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 :)
>
| |
|
| Hi,
I use
if Not BinaryStream.EOS Then Response.BinaryWrite
outside the loop to get the remainder. But still no luck with larger
files
:)
Jon Paal wrote:[color=darkred]
> I don't have sample code, but if the remainder of the file size is not equal to your block size it may not finish downloading. Test
> for remainder size then reset block size to capture that last amount.
>
> you will need to google for sample code it's been done many times.
>
>
>
>
> "Katie" <DnkyCartRcr@gmail.com> wrote in message news:1161271398.418064.128390@h48g2000cwc.googlegroups.com...
| |
| Jon Paal 2006-10-30, 6:58 pm |
| look at sample here....
http://support.jodohost.com/archive...php/t-3511.html
"Katie" <DnkyCartRcr@gmail.com> wrote in message news:1161283027.718768.100040@b28g2000cwb.googlegroups.com...
> Hi,
>
> I use
> if Not BinaryStream.EOS Then Response.BinaryWrite
> outside the loop to get the remainder. But still no luck with larger
> files
>
> :)
>
> Jon Paal wrote:
>
| |
| Anthony Jones 2006-10-30, 6:58 pm |
|
"Katie" <DnkyCartRcr@gmail.com> wrote in message
news:1161271398.418064.128390@h48g2000cwc.googlegroups.com...
> 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.
| |
| Egbert Nierop \(MVP for IIS\) 2006-10-30, 6:58 pm |
|
"Katie" <DnkyCartRcr@gmail.com> wrote in message
news:1161271398.418064.128390@h48g2000cwc.googlegroups.com...
> 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
|
|
|
|
|