473,320 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 12620
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: atse | last post by:
Hi, I want the MP3 audio files to be able to download by users only. Even I set the pages validated by session, anyone still can type the download url to get my files without access of the pages...
5
by: Eric Sabine | last post by:
I have a web site where the user is able to download a file. I can't use an anchor tag because I don't want the user to see where the filename is coming from. Below is the code in which the user...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
5
by: Tom Gurath | last post by:
http://osnews.com/story.php?news_id=5602&page=2 This benchmark tests the Math & File I/O of 9 languages/run-times. Visual C++ (Version 7 - not managed) Visual C# gcc C Visual Basic.NET Visual...
2
by: mpaliath | last post by:
Hi guys I am currently involved in a project which requires me to recieve and play streaming video as well as send it. In Visual C++ is there any free library which helps me do this as...
7
by: CJM | last post by:
I have a page on our intranet that is supposed to stream an Excel sheet to the user. I'm using pretty standard code: sFilePath = sFileDir & sFilename Response.AddHeader...
5
by: pmakoi | last post by:
dear all this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic I am...
6
by: Brybot | last post by:
I am trying to allow HTTP POST file uploads to my web service. Currently I have it working perfectly for a SOAP/XML request reading in a byte using MemoryStream/FileStream but I cannot figure out...
6
by: Gilly | last post by:
Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing...
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all On SQL Server tables I use SqlDataReader to query data like "SELECT * FROM table". Is there something similar for XML Files ? I want to use SQL Syntax like "SELECT * FROM table" on a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.