0

我们从 Windows Server 2003 转到 Windows Server 2008,我们的 FileSystemObject 脚本不再工作。每当我们尝试下载 10-12 Mb 的文件时,它都会导致下载时间很短,即:有时只能下载 15、19 或 22 Mb 的 26 Mb 文件。

服务器设置为允许 40+ Mb 的下载没有问题,这已通过直接 http 下载到根级别的文件得到证实……在 32 Mb 上的直接下载测试成功率 100%。但是,我们需要提供存储在根目录下的文件的下载,因此我们需要使用 FSO 脚本。

我们已经在 Windows Server 2003 上成功使用该脚本几年了,但最近我们无法从 Windows Server 2008 获得完整下载。

strChunkSize = 1024000*1    
strDocFile = "someDocument.doc"
FPath = "C:\data\" & strDocFile
Response.Buffer = True
Response.Clear

Set adoStream = CreateObject("ADODB.Stream") 
adoStream.Open() 
adoStream.Type = 1 

on error resume next

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fl = fso.GetFile(FPath)
intFilelength = fl.size

adoStream.LoadFromFile(FPath)

Response.AddHeader "Content-Disposition", "attachment; filename=" & fl.name
Response.AddHeader "Content-Length", intFilelength
Response.AddHeader "Accept-Ranges", "bytes"
Response.ContentType = "application/octet-stream"

For i = 0 To adoStream.Size
i = i + strChunkSize
Response.BinaryWrite(adoStream.Read(strChunkSize))
Response.Flush
Next

adoStream.Close
Set adoStream = Nothing 

我已经在其他地方深入检查了这个主题,并且 FSO 下载脚本的每个示例都失败了,即使对任何大于 4 Mb 的文件使用块也是如此。

4

1 回答 1

0

这种情况下的问题是脚本超时,默认情况下只有 90 秒,因此大文件被停止使用。为了解决这个问题,我添加了一些脚本来设置与下载成正比的超时时间,并允许慢速教练......

if strDocFileSize <> "" then
strScriptTimeout = (strDocFileSize/1024000)*40
else
strScriptTimeout = 30000
end if

Server.ScriptTimeout = strScriptTimeout
于 2013-08-08T08:39:53.950 回答