sending HUGE file to client via Response.BinaryWrite

Discussion in 'ASP General' started by Zam, Mar 10, 2005.

  1. Zam

    Zam Guest

    Hello World,

    Under Windows 2003 Server. IIS6.

    The following code working fine for small files, and for files with size
    about few megabytes.

    If I am trying to send HUGE file -- about 700 Megabyte -- w3wp.exe eat all
    memory (I have 1024 megabytes) and all CPU time without positive result.

    Question: how could i _clever_ and fast send very huge file to client, with
    keeping "file location privacy" ?

    Response.Buffer = False
    Server.ScriptTimeout = 30000

    Response.ContentType = "application/x-unknown"
    fn = "movie1.avi"
    FPath = "g:\movies\" & fn
    Response.AddHeader "Content-Disposition", "attachment; filename=" & fn

    Set adoStream = CreateObject("ADODB.Stream")
    chunk = 2048
    adoStream.Type = 1

    iSz = adoStream.Size

    Response.AddHeader "Content-Length", iSz

    For i = 1 To iSz \ chunk
    If Not Response.IsClientConnected Then Exit For
    Response.BinaryWrite adoStream.Read(chunk)

    If iSz Mod chunk > 0 Then
    If Response.IsClientConnected Then
    Response.BinaryWrite objStream.Read(iSz Mod chunk)
    End If
    End If

    Set adoStream = Nothing


    With best regards,
    Zam, Mar 10, 2005
    1. Advertisements

  2. Zam

    Mark Schupp Guest

    Not familiar with streams so this is mostly a guess but you might try making
    sure that the stream's "mode" is set to adModeRead (=1).
    Mark Schupp, Mar 10, 2005
    1. Advertisements

  3. Zam

    Zam Guest

    Hello Mark,

    Unfortunatly, the same negative result (eat all RAM and CPU time):

    Error number: -2147024882
    Error description: Not enough storage is available to complete this

    Error line: adoStream.LoadFromFile(FPath)

    With best regards,
    Zam, Mar 11, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.