简体   繁体   English

下载 APK 在 Chrome 浏览器中不起作用

[英]Download APK not working in Chrome browser

My website has an option to download the apk file.我的网站有一个下载 apk 文件的选项。 The file is getting correctly downloaded in all other Android browsers except Chrome.该文件已在除 Chrome 之外的所有其他 Android 浏览器中正确下载。

Getting a warning as "Resource interpreted as document but transfered with Mime type application / octet-stream".收到警告“资源被解释为文档,但已通过 Mime 类型应用程序/八位字节流传输”。 I have implemented below code but it is not working.我已经实现了下面的代码,但它不起作用。

Java code:爪哇代码:

String filename = 'Sample.apk';
String filepath = '/resources/mobileapp/';
MimetypesFileTypeMap mimetypesFileTypeMap = new MimetypesFileTypeMap();
response.setContentType(mimetypesFileTypeMap.getContentType(filepath + filename));
response.setHeader('Content-Disposition', "attachment; filename=\"" + filename + "\");

It means that the server is sending a Javascript HTTP response with这意味着服务器正在发送一个 Javascript HTTP 响应

Content-Type: text/plain

You need to configure the server to send a JavaScript response with您需要配置服务器以发送 JavaScript 响应

 Content-Type: application/javascript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM