将网站上的文件下载到Android设备失败

时间:2014-11-19 04:25:54

标签: android .net vb.net android-download-manager

我有一个应用程序,我们将文件从安全的加密文件系统提供给用户。文件由应用程序即时解密,然后通过响应头推送到客户端。这适用于所有浏览器和iOS设备,但在所有机器人上都失败了。它只是说下载失败了。

我已经尝试过针对Android设备提出的许多不同的解决方案,因为它们似乎对这样的文件有很多问题。似乎没有任何效果。

  • 将文件扩展名更改为Content-Disposition标题中的所有大写字母
  • 尝试了多种内容类型(应用程序/八位字节流和特定文件类型)

以下是编写响应标头的实际代码。

strMimeType = objDocument.FileMime
If strMimeType = "" Then
    strMimeType = "application/octet-stream"
End If
HttpContext.Current.Response.ContentType = strMimeType
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & objDocument.Filename)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.WriteFile(Server.MapPath("/FS/CO/" & objDocument.DocumentID & "/" & objDocument.Filename))
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.Close()
HttpContext.Current.Response.End()

1 个答案:

答案 0 :(得分:0)

这对我有用 - adb logcat DownloadManager:I *:S

在adb logcat中只显示来自downloadmanager的内容。我在三星Galaxy s4上,所以如果你有不同的东西,你可能需要通过谷歌找出你的下载管理器的名称,或者启动日志:使用“adb logcat”做那个,然后下载文件然后快速向上滚动以阻止adb打印更多内容,然后找到它。

我遇到了这个问题: I / DownloadManager(9250):发起下载id = 2011的请求,其中mAllowedNetworkTypes = -1 forP2Pbit = 8194 W / DownloadManager(9250):中止2011年下载请求:http错误403,mContinuingDownload:false FinalStatus = 403

我认为它与我的服务器有关但我的服务器工作得很好。所以我不确定为什么它会破碎