Home All Groups Group Topic Archive Search About

throttling download in ASP



Author
28 Aug 2006 8:53 PM
Katie
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

Show quote
:)

Author
29 Aug 2006 11:10 AM
Anthony Jones
Show quote
"Katie" <DnkyCart***@gmail.com> wrote in message
news:1156798438.185741.36420@m79g2000cwm.googlegroups.com...
> 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.
Author
29 Aug 2006 11:46 AM
Katie
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:
Show quote
> "Katie" <DnkyCart***@gmail.com> wrote in message
> news:1156798438.185741.36420@m79g2000cwm.googlegroups.com...
> > 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.
Author
29 Aug 2006 12:16 PM
Anthony Jones
Show quote
"Katie" <DnkyCart***@gmail.com> wrote in message
news:1156851967.481782.104440@m73g2000cwd.googlegroups.com...
> 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?

Show quote
> Anthony Jones wrote:
> > "Katie" <DnkyCart***@gmail.com> wrote in message
> > news:1156798438.185741.36420@m79g2000cwm.googlegroups.com...
> > > 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.
>
Author
29 Aug 2006 5:37 PM
B
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:
Show quote
> "Katie" <DnkyCart***@gmail.com> wrote in message
> news:1156798438.185741.36420@m79g2000cwm.googlegroups.com...
> > 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.

AddThis Social Bookmark Button