0

I use the follwoing code to push a large ZIP file to the client using vbscript (Classic asp). I am not sure how objStream.Read(10240) works? Does it send data to the client in chunks (or loads the file in memory chunks)? Should I also use Response.buffer= true (or false?) or those chunks with response.flush automatically release the server buffer size?

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1 'adTypeBinary
objStream.Open
objStream.LoadFromFile(server.mappath("test.zip"))

Response.ContentType = "application/zip"
Response.Addheader "Content-Disposition", "attachment; filename=test.zip"

do while not objStream.EOS
    response.binarywrite objStream.Read(10240)
    Response.Flush
loop
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82
  • Did we not cover this in [your other question](https://stackoverflow.com/questions/64178081/can-i-load-concurrent-large-files-using-adodb-stream#comment113513586_64178081)? – user692942 Oct 13 '20 at 09:56
  • 1
    From [the docs](https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524318(v=vs.90)) - *"An ASP application uses internal server buffers when writing data to the client, irrespective of the value of `Response.Buffer`."* – user692942 Oct 13 '20 at 10:00
  • Thank you @Lankymart. When I use the above code to load a MP4 into vdeio player, only 73 MegaByte of file is being transfered and the video stops after that. I don't know what limit is being reached? Buffer size? Script timeout? CPU? RAM? – Ali Sheikhpour Oct 13 '20 at 10:56
  • It's likely the `Script.Timeout` think about how much data you're pulling in each read and maybe try increasing it to get the best performance. For example, say a video was 2 GB in size and we say it takes 100 ms to read each chunk of 10 KB it would take approx. 6 hours. Ref [ASP Classic, Download big files does not work on certain servers](https://stackoverflow.com/a/39141269) – user692942 Oct 13 '20 at 15:40
  • Thank you @Lankymart. I have found an special discussion about handling Video files with the name RangeDownload. I am trying to convert it to vbscript codes. – Ali Sheikhpour Oct 13 '20 at 15:49
  • 1
    Good luck that's some heavy going in a Classic ASP project (binary representation etc), personally just increasing the chunk size a bit will have a huge impact on the performance, it's just a bit of trial n error and some maths. – user692942 Oct 13 '20 at 15:52
  • 1
    Yes sir increasing the chunk size imroved the performance. Thank you for supporting Calssic-asp in the age of lazy programmers with .net :D @Lankymart – Ali Sheikhpour Oct 13 '20 at 16:18

0 Answers0