alexmindel
asked on
Problem to download Large mp3 file (over 4MB) using ADODB.Stream
Hi,
I created a code to download different files (jpg, gif, mp3, wma) from the client's website. I use ADODB.Stream object.
I don't have any problems with jpg and gif formats. When I try to download mp3/wma files I get IE msg: IE cannot open this site. I defined that the problem is in the file size. If file is over 4MB (Response.BinaryWrite adoStream.Read(4194000) ) I can't download it.
I tested already different solutions like:
1. Change timeout, buffer, flush.
2. Chunk
Nothing!!! Plus I can't use any COM that needs to be registered on provider's server. Please review my code below.
I hope to get any solution ASAP.
Thanks.
************************** ********** ********** ********** ********** ********** ***
Private Sub DownloadFile(file)
Dim strAbsFile, objFSO, objFile, adoStream
Response.Buffer = False
strAbsFile = Server.MapPath(file)
Set objFSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
If objFSO.FileExists(strAbsFi le) Then
Set objFile = objFSO.GetFile(strAbsFile)
Response.ContentType = "application/x-unknown"
Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
Response.AddHeader "Content-Length", objFile.Size
Set adoStream = CreateObject("ADODB.Stream ")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(str AbsFile)
Response.BinaryWrite adoStream.Read(4194000) ' <-- if file size is over then IE Msg: IE cannot open this site.
adoStream.Close
Set adoStream = Nothing
Response.End
end if
Set objFile = Nothing
end sub
I created a code to download different files (jpg, gif, mp3, wma) from the client's website. I use ADODB.Stream object.
I don't have any problems with jpg and gif formats. When I try to download mp3/wma files I get IE msg: IE cannot open this site. I defined that the problem is in the file size. If file is over 4MB (Response.BinaryWrite adoStream.Read(4194000) ) I can't download it.
I tested already different solutions like:
1. Change timeout, buffer, flush.
2. Chunk
Nothing!!! Plus I can't use any COM that needs to be registered on provider's server. Please review my code below.
I hope to get any solution ASAP.
Thanks.
**************************
Private Sub DownloadFile(file)
Dim strAbsFile, objFSO, objFile, adoStream
Response.Buffer = False
strAbsFile = Server.MapPath(file)
Set objFSO = Server.CreateObject("Scrip
If objFSO.FileExists(strAbsFi
Set objFile = objFSO.GetFile(strAbsFile)
Response.ContentType = "application/x-unknown"
Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
Response.AddHeader "Content-Length", objFile.Size
Set adoStream = CreateObject("ADODB.Stream
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(str
Response.BinaryWrite adoStream.Read(4194000) ' <-- if file size is over then IE Msg: IE cannot open this site.
adoStream.Close
Set adoStream = Nothing
Response.End
end if
Set objFile = Nothing
end sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
i've tested it with 25M files, and the only problem (minus the timeout error which I fixed) is that it takes a little time to download it, but it does work
ASKER
Thank you for your quick responds. I used your function but I can't still open mp3 file.
When I click on the link "download", the download popup does not appear but looks like procedure is running.
In 2-3 minutes the blank page is opened. What do you think about it?
When I click on the link "download", the download popup does not appear but looks like procedure is running.
In 2-3 minutes the blank page is opened. What do you think about it?
can you download another file type?, a .doc, .zip perhaps?
ASKER
I tested txt, doc, jpg and gif. They worked fine. Zip file had a size over 4MB. Thus, I couldn't download it.
Probably, I'll not be able to download any files over 4MB.
Probably, I'll not be able to download any files over 4MB.
what happens if you don't use any script...ie..link to the file itslef?
try out the function this person posted @:
https://www.experts-exchange.com/questions/21795098/Files-corrupted-using-BinaryWrite.html
https://www.experts-exchange.com/questions/21795098/Files-corrupted-using-BinaryWrite.html
ASKER
I used that last variant before and got same problem: downloaded files were corrupted.
If I use direct link to the file itself it works perfect (only popup doesn't appear). I think that is the sream object problem.
Thus, I am gonna do the following: convert mp3 files to wma format (size will be around 2MB). But It is not the real solution: problem is still there.
Thank you, kevp75, for your time and help. Let me know if you find anything else later. That would be interesting because the same problem will appear from time to time.
Best regards,
Alex.
If I use direct link to the file itself it works perfect (only popup doesn't appear). I think that is the sream object problem.
Thus, I am gonna do the following: convert mp3 files to wma format (size will be around 2MB). But It is not the real solution: problem is still there.
Thank you, kevp75, for your time and help. Let me know if you find anything else later. That would be interesting because the same problem will appear from time to time.
Best regards,
Alex.
will do alex.....np