Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > sending HUGE file to client via Response.BinaryWrite

Reply
Thread Tools

sending HUGE file to client via Response.BinaryWrite

 
 
Zam
Guest
Posts: n/a
 
      03-10-2005
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.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)

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)
Next

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

adoStream.Close
Set adoStream = Nothing

Response.End
%>

With best regards,


 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      03-10-2005
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
Head of Development
Integrity eLearning
www.ielearning.com


"Zam" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Open()
> adoStream.Type = 1
> adoStream.LoadFromFile(FPath)
>
> 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)
> Next
>
> If iSz Mod chunk > 0 Then
> If Response.IsClientConnected Then
> Response.BinaryWrite objStream.Read(iSz Mod chunk)
> End If
> End If
>
> adoStream.Close
> Set adoStream = Nothing
>
> Response.End
> %>
>
> With best regards,
>
>



 
Reply With Quote
 
 
 
 
Zam
Guest
Posts: n/a
 
      03-11-2005
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
operation.

Error line: adoStream.LoadFromFile(FPath)

With best regards,

"Mark Schupp" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Zam" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.Open()
> > adoStream.Type = 1
> > adoStream.LoadFromFile(FPath)
> >
> > 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)
> > Next
> >
> > If iSz Mod chunk > 0 Then
> > If Response.IsClientConnected Then
> > Response.BinaryWrite objStream.Read(iSz Mod chunk)
> > End If
> > End If
> >
> > adoStream.Close
> > Set adoStream = Nothing
> >
> > Response.End
> > %>
> >
> > With best regards,
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory error due to the huge/huge input file size tejsupra@gmail.com Python 3 11-20-2008 07:21 PM
Sending binary data to client printer via web page. =?Utf-8?B?U2Nod2FydHk=?= ASP .Net 4 02-13-2006 09:06 AM
Sending xls file from Server to Client via asp.net Lars Netzel ASP .Net 1 11-10-2005 03:07 PM
Sending File from Server to WebClient via Response Lars Netzel ASP .Net 3 11-07-2005 12:45 PM
Sending pictures via email Via OE6+Win XP - I no longer get prompt to "make all my pictures smaller" Ian Roberts Digital Photography 3 09-21-2003 04:57 PM



Advertisments