473,224 Members | 1,461 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,224 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 12607
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.