【发布时间】:2015-11-10 18:34:41
【问题描述】:
我正在尝试使用 adodb 将文件流式传输到浏览器。
用户会得到一个这样的选项:
Save File 选项按预期工作。
但是Open with Firefox 选项给出了gobbledy,并且.htm 被附加到文件名的末尾。
我推测这与Response.ContentType 的设置有关。
我尝试过使用application/pdf、application/octet-stream 和application/x-unknown。但无论我使用哪个,我总是得到相同的结果。
这是怎么回事?我应该使用什么 ContentType?
使用 Firefox 打开的截图
ADODB 流代码
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objStream.LoadFromFile(fileDirectory & "\" & fileToDownload)
Response.AddHeader "Expires", "0"
Response.AddHeader "Content-Transfer-Encoding", "binary"
Response.AddHeader "Content-Description", "File Transfer"
Response.AddHeader "Content-Disposition", "attachment; filename=" & fileToDownload
Response.AddHeader "Content-Length", objStream.Size
Response.CharSet = "UTF-8"
Response.ContentType = "???" // *** what should I put here? ***
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
【问题讨论】:
标签: asp-classic stream mime-types content-type adodb