469,327 Members | 1,315 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

ASP File Streaming

I have the following code which works fine downloading smaller files, the
trouble is most of the files to be downloaded are large. With large files it
just returns a HTTP 500 error.

Any ideas how to get this to work. I have tried to split the download into
chunks but it just timesout.

Set objFile = objFSO.GetFile(strFileName)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" &
strFileName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strFileName)
'-- send the stream in the response

Response.BinaryWrite(objStream.Read)
Response.Flush
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
Jul 22 '05 #1
3 12290
Further to this I am now trying to break the code into chunks again. Here is
the code. Everything works until I get to the line zzz=BA.Read(100) and it
returns a HTTP 500 Error. Any ideas?

Dim FileSize, ByteCounter, FileName, ChunkSize

ChunkSize = 1024
FileName = Trim(Request.QueryString("File"))
FileSize =
CreateObject("scripting.filesystemobject").GetFile (FileName).Size

'This is download
Response.ContentType = "application/x-msdownload"

'Set file name
Response.AddHeader "Content-Disposition", "attachment; filename=""" &
GetFileName(FileName) & """"

'Set Content-Length (ASP doen not set it when Buffer = False)
Response.AddHeader "Content-Length", FileSize
Response.CacheControl = "no-cache"

Dim BA
' Set BA = CreateObject("ScriptUtils.ByteArray")'
Set BA = Server.CreateObject("ADODB.Stream")
BA.Open
BA.LoadFromFile(FileName)
zzz= BA.Read(100)

"James Whitehead" <Ja***@whitehead.co.uk> wrote in message
news:#R**************@tk2msftngp13.phx.gbl...
I have the following code which works fine downloading smaller files, the
trouble is most of the files to be downloaded are large. With large files it just returns a HTTP 500 error.

Any ideas how to get this to work. I have tried to split the download into
chunks but it just timesout.

Set objFile = objFSO.GetFile(strFileName)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" &
strFileName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strFileName)
'-- send the stream in the response

Response.BinaryWrite(objStream.Read)
Response.Flush
objStream.Close
Set objStream = Nothing
Set objFile = Nothing

Jul 22 '05 #2
Maybe try this code instead? See last listing on the page...

http://www.4guysfromrolla.com/webtech/083100-1.shtml

Tim
"James Whitehead" <Ja***@whitehead.co.uk> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Further to this I am now trying to break the code into chunks again.
Here is
the code. Everything works until I get to the line zzz=BA.Read(100)
and it
returns a HTTP 500 Error. Any ideas?

Dim FileSize, ByteCounter, FileName, ChunkSize

ChunkSize = 1024
FileName = Trim(Request.QueryString("File"))
FileSize =
CreateObject("scripting.filesystemobject").GetFile (FileName).Size

'This is download
Response.ContentType = "application/x-msdownload"

'Set file name
Response.AddHeader "Content-Disposition", "attachment; filename="""
&
GetFileName(FileName) & """"

'Set Content-Length (ASP doen not set it when Buffer = False)
Response.AddHeader "Content-Length", FileSize
Response.CacheControl = "no-cache"

Dim BA
' Set BA = CreateObject("ScriptUtils.ByteArray")'
Set BA = Server.CreateObject("ADODB.Stream")
BA.Open
BA.LoadFromFile(FileName)
zzz= BA.Read(100)

"James Whitehead" <Ja***@whitehead.co.uk> wrote in message
news:#R**************@tk2msftngp13.phx.gbl...
I have the following code which works fine downloading smaller
files, the
trouble is most of the files to be downloaded are large. With large
files

it
just returns a HTTP 500 error.

Any ideas how to get this to work. I have tried to split the
download into
chunks but it just timesout.

Set objFile = objFSO.GetFile(strFileName)
'-- first clear the response, and then set the appropriate
headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment;
filename=" &
strFileName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strFileName)
'-- send the stream in the response

Response.BinaryWrite(objStream.Read)
Response.Flush
objStream.Close
Set objStream = Nothing
Set objFile = Nothing


Jul 22 '05 #3
Cool thanks will have a look
"Tim Williams" <saxifrax@pacbell*dot*net> wrote in message
news:eH**************@TK2MSFTNGP14.phx.gbl...
Maybe try this code instead? See last listing on the page...

http://www.4guysfromrolla.com/webtech/083100-1.shtml

Tim
"James Whitehead" <Ja***@whitehead.co.uk> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Further to this I am now trying to break the code into chunks again.
Here is
the code. Everything works until I get to the line zzz=BA.Read(100)
and it
returns a HTTP 500 Error. Any ideas?

Dim FileSize, ByteCounter, FileName, ChunkSize

ChunkSize = 1024
FileName = Trim(Request.QueryString("File"))
FileSize =
CreateObject("scripting.filesystemobject").GetFile (FileName).Size

'This is download
Response.ContentType = "application/x-msdownload"

'Set file name
Response.AddHeader "Content-Disposition", "attachment; filename="""
&
GetFileName(FileName) & """"

'Set Content-Length (ASP doen not set it when Buffer = False)
Response.AddHeader "Content-Length", FileSize
Response.CacheControl = "no-cache"

Dim BA
' Set BA = CreateObject("ScriptUtils.ByteArray")'
Set BA = Server.CreateObject("ADODB.Stream")
BA.Open
BA.LoadFromFile(FileName)
zzz= BA.Read(100)

"James Whitehead" <Ja***@whitehead.co.uk> wrote in message
news:#R**************@tk2msftngp13.phx.gbl...
I have the following code which works fine downloading smaller
files, the
trouble is most of the files to be downloaded are large. With large
files

it
just returns a HTTP 500 error.

Any ideas how to get this to work. I have tried to split the
download into
chunks but it just timesout.

Set objFile = objFSO.GetFile(strFileName)
'-- first clear the response, and then set the appropriate
headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment;
filename=" &
strFileName
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strFileName)
'-- send the stream in the response

Response.BinaryWrite(objStream.Read)
Response.Flush
objStream.Close
Set objStream = Nothing
Set objFile = Nothing



Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by atse | last post: by
5 posts views Thread by Eric Sabine | last post: by
2 posts views Thread by mpaliath | last post: by
5 posts views Thread by pmakoi | last post: by
9 posts views Thread by =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.