throttling download in ASP

Discussion in 'ASP General' started by Katie, Aug 28, 2006.

  1. Katie

    Katie Guest

    Hi,

    I am downloading files using ASP using the the binarywrite as below.

    objStream.LoadFromFile(strAbsFile)
    '-- send the stream in the response
    Response.BinaryWrite(objStream.Read)

    I was wondering is there any way I can control or throttle the
    download?. I want to make sure that the users are not taking up too
    much bandwidth while downloading the file.

    Thanks for your help and time

    :)
    Katie, Aug 28, 2006
    #1
    1. Advertising

  2. "Katie" <> wrote in message
    news:...
    > Hi,
    >
    > I am downloading files using ASP using the the binarywrite as below.
    >
    > objStream.LoadFromFile(strAbsFile)
    > '-- send the stream in the response
    > Response.BinaryWrite(objStream.Read)
    >
    > I was wondering is there any way I can control or throttle the
    > download?. I want to make sure that the users are not taking up too
    > much bandwidth while downloading the file.
    >
    > Thanks for your help and time
    >
    > :)
    >


    The only way to do this without using an additional component is to put this
    file in it's own application and enable I/O throttling (although that will
    apply to all downloads currently in progress).

    What version of IIS are you using?

    I assume you have Response.Buffer = false in the code?

    You should note that even with buffer = false the buffer limit is still in
    effect for any single call to BinaryWrite. On IIS6 the default limit is 4MB
    hence a file larger than this will break the limit. I would recommend that
    you use a for loop to chunk the contents to BinaryWrite. This does have the
    effect of slowing the download (with no buffer, binarywrite will become
    dependant of client acknowledgments) so use a chunk size of say 2Mb to
    minimize this impact.

    If you can build and use additional components you can use a chunking loop
    to control bandwidth usage by using the sleep API to pause the loop a
    little.

    Anthony.
    Anthony Jones, Aug 29, 2006
    #2
    1. Advertising

  3. Katie

    Katie Guest

    Below is a sub I wrote to download files by using response.binarywrite.
    The code works fine, but is there any way to throttle it so that if the
    clients are downloading large files (several hundred megs) they dont
    take up all the bandwidth. I think the IIS version is 5, but ill
    confirm that with the sys admin

    thanks for ure help
    :)

    Private Sub streamDocs(path, filename, originalFileName, contentType)

    Response.AddHeader
    "content-disposition","attachment;filename="&originalFileName
    Response.ContentType = contentType
    Dim BinaryStream, Fil, fs
    Set BinaryStream = CreateObject("ADODB.Stream")

    set fs = Server.CreateObject("Scripting.FileSystemObject")

    Set Fil = fs.GetFile(path & "\" &filename) 'Open file

    BinaryStream.Type = 1
    BinaryStream.Open
    BinaryStream.LoadFromFile Fil.path
    Response.BinaryWrite BinaryStream.Read
    BinaryStream.Cancel
    BinaryStream.Close
    set BinaryStream = nothing

    End sub
    Anthony Jones wrote:
    > "Katie" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I am downloading files using ASP using the the binarywrite as below.
    > >
    > > objStream.LoadFromFile(strAbsFile)
    > > '-- send the stream in the response
    > > Response.BinaryWrite(objStream.Read)
    > >
    > > I was wondering is there any way I can control or throttle the
    > > download?. I want to make sure that the users are not taking up too
    > > much bandwidth while downloading the file.
    > >
    > > Thanks for your help and time
    > >
    > > :)
    > >

    >
    > The only way to do this without using an additional component is to put this
    > file in it's own application and enable I/O throttling (although that will
    > apply to all downloads currently in progress).
    >
    > What version of IIS are you using?
    >
    > I assume you have Response.Buffer = false in the code?
    >
    > You should note that even with buffer = false the buffer limit is still in
    > effect for any single call to BinaryWrite. On IIS6 the default limit is 4MB
    > hence a file larger than this will break the limit. I would recommend that
    > you use a for loop to chunk the contents to BinaryWrite. This does have the
    > effect of slowing the download (with no buffer, binarywrite will become
    > dependant of client acknowledgments) so use a chunk size of say 2Mb to
    > minimize this impact.
    >
    > If you can build and use additional components you can use a chunking loop
    > to control bandwidth usage by using the sleep API to pause the loop a
    > little.
    >
    > Anthony.
    Katie, Aug 29, 2006
    #3
  4. "Katie" <> wrote in message
    news:...
    > Below is a sub I wrote to download files by using response.binarywrite.
    > The code works fine, but is there any way to throttle it so that if the
    > clients are downloading large files (several hundred megs) they dont
    > take up all the bandwidth. I think the IIS version is 5, but ill
    > confirm that with the sys admin
    >
    > thanks for ure help
    > :)
    >
    > Private Sub streamDocs(path, filename, originalFileName, contentType)
    >
    > Response.AddHeader
    > "content-disposition","attachment;filename="&originalFileName
    > Response.ContentType = contentType
    > Dim BinaryStream, Fil, fs
    > Set BinaryStream = CreateObject("ADODB.Stream")
    >
    > set fs = Server.CreateObject("Scripting.FileSystemObject")
    >
    > Set Fil = fs.GetFile(path & "\" &filename) 'Open file
    >
    > BinaryStream.Type = 1
    > BinaryStream.Open
    > BinaryStream.LoadFromFile Fil.path
    > Response.BinaryWrite BinaryStream.Read
    > BinaryStream.Cancel
    > BinaryStream.Close
    > set BinaryStream = nothing
    >
    > End sub


    This doesn't really tell me anything new. The short answer is no.
    However the advice I have already given still stands.

    BTW why FileSystemObject? doesn't:-

    BinaryStream.LoadFromFile path & "\" & filename

    work for you?

    Also what does:-

    BinaryStream.Cancel

    do?

    > Anthony Jones wrote:
    > > "Katie" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > I am downloading files using ASP using the the binarywrite as below.
    > > >
    > > > objStream.LoadFromFile(strAbsFile)
    > > > '-- send the stream in the response
    > > > Response.BinaryWrite(objStream.Read)
    > > >
    > > > I was wondering is there any way I can control or throttle the
    > > > download?. I want to make sure that the users are not taking up too
    > > > much bandwidth while downloading the file.
    > > >
    > > > Thanks for your help and time
    > > >
    > > > :)
    > > >

    > >
    > > The only way to do this without using an additional component is to put

    this
    > > file in it's own application and enable I/O throttling (although that

    will
    > > apply to all downloads currently in progress).
    > >
    > > What version of IIS are you using?
    > >
    > > I assume you have Response.Buffer = false in the code?
    > >
    > > You should note that even with buffer = false the buffer limit is still

    in
    > > effect for any single call to BinaryWrite. On IIS6 the default limit is

    4MB
    > > hence a file larger than this will break the limit. I would recommend

    that
    > > you use a for loop to chunk the contents to BinaryWrite. This does have

    the
    > > effect of slowing the download (with no buffer, binarywrite will become
    > > dependant of client acknowledgments) so use a chunk size of say 2Mb to
    > > minimize this impact.
    > >
    > > If you can build and use additional components you can use a chunking

    loop
    > > to control bandwidth usage by using the sleep API to pause the loop a
    > > little.
    > >
    > > Anthony.

    >
    Anthony Jones, Aug 29, 2006
    #4
  5. Katie

    B Guest

    Hi,

    Thanks for your email.
    I am a little confused regarding the loop you are talking about.

    I appologize for posting on more than one group, i wasnt sure which
    group this would fit under

    Thanks
    :)

    Anthony Jones wrote:
    > "Katie" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I am downloading files using ASP using the the binarywrite as below.
    > >
    > > objStream.LoadFromFile(strAbsFile)
    > > '-- send the stream in the response
    > > Response.BinaryWrite(objStream.Read)
    > >
    > > I was wondering is there any way I can control or throttle the
    > > download?. I want to make sure that the users are not taking up too
    > > much bandwidth while downloading the file.
    > >
    > > Thanks for your help and time
    > >
    > > :)
    > >

    >
    > The only way to do this without using an additional component is to put this
    > file in it's own application and enable I/O throttling (although that will
    > apply to all downloads currently in progress).
    >
    > What version of IIS are you using?
    >
    > I assume you have Response.Buffer = false in the code?
    >
    > You should note that even with buffer = false the buffer limit is still in
    > effect for any single call to BinaryWrite. On IIS6 the default limit is 4MB
    > hence a file larger than this will break the limit. I would recommend that
    > you use a for loop to chunk the contents to BinaryWrite. This does have the
    > effect of slowing the download (with no buffer, binarywrite will become
    > dependant of client acknowledgments) so use a chunk size of say 2Mb to
    > minimize this impact.
    >
    > If you can build and use additional components you can use a chunking loop
    > to control bandwidth usage by using the sleep API to pause the loop a
    > little.
    >
    > Anthony.
    B, Aug 29, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    2,330
    Jim Higson
    Jun 20, 2006
  2. Simon Roust
    Replies:
    1
    Views:
    468
    Mr. Arnold
    Apr 16, 2010
  3. thoolen

    Re: throttling

    thoolen, Jul 26, 2011, in forum: Java
    Replies:
    2
    Views:
    262
    thoolen
    Jul 27, 2011
  4. Jim

    Trouble with throttling fork()

    Jim, Oct 3, 2003, in forum: Perl Misc
    Replies:
    6
    Views:
    102
    Steve East
    Oct 7, 2003
  5. Question of throttling CPU usage

    , Apr 25, 2012, in forum: C Programming
    Replies:
    16
    Views:
    830
    Robert Miles
    May 28, 2012
Loading...

Share This Page