简体   繁体   中英

Download APK not working in Chrome browser

My website has an option to download the apk file. The file is getting correctly downloaded in all other Android browsers except Chrome.

Getting a warning as "Resource interpreted as document but transfered with Mime type application / octet-stream". 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

Content-Type: text/plain

You need to configure the server to send a JavaScript response with

 Content-Type: application/javascript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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