Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Must large files be downloaded in blocks?

Status
Not open for further replies.

dermie

Programmer
May 2, 2004
8
IL
Currently, users can download mp3 files from my website PROVIDED the files are relatively small. With large files (4 mega), the files do not download. I understand that large files must be downloaded in blocks. How does one do this??

My current code reads as follows:

<%
Set filesys = CreateObject("Scripting.FileSystemObject")

strWav = "/media/"&Request.Form("code1")&Request.Form("code2")&Request.Form("code3")&".mp3"

strFilename = server.MapPath(strWav)

If filesys.FileExists(strFilename) Then

strFilename = server.MapPath(strWav)

Response.Buffer = True
Response.Clear

Set s = Server.CreateObject("ADODB.Stream")

s.Open
s.Type = 1

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFilename)

intFilelength = f.size

s.LoadFromFile(strFilename)

Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.Charset = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush

s.Close
Set s = Nothing

Else

response.write "Sorry, your file is not yet prepared or else you entered the wrong name and number codes.</b></font>"

End If

%>
 
This is guesswork (so sorry if I am wrong)

How big is the content length (16 bit or 32 bit ?), and does it represent bytes or Kb? I would guess 32 bit, and you are setting your header to a 4 mb limit.

So, i would guess that you need to create 2 files, a part a, and part b. Then open the fso on the master, and copy the header, then the first X mb of data to file a. Then Output the next block to file B. But, how will your user know to reconstruct them ?

You may be better to zip the files up, unless you are streaming them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top