How to download ".apk" as ".apk"? (not as ".zip")
I have a small problem. Some browsers are not downloading the ".apk" files correctly. How to download ".ap开发者_如何学编程k" as ".apk"? (not as ".zip") Some browsers are convert them to ".zip".
I mean, the ".apk" file on my server and some people calling me and asking, how to rename ".zip" to ".apk".
Create a MIME-TYPE mapping of apk
to application/vnd.android.package-archive
. How you do this will vary on your web server.
For IIS7 and higher, add the following to the web.config
of your application:
<system.webServer>
<staticContent>
<mimeMap fileExtension="apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
<system.webServer>
You can also set in web.config for local server for downloading apk
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
</configuration>
Commit an answer for Nginx:
Add this line in mime.types,
application/vnd.android.package-archive apk;
If this won't work, try to return an explicit header for *.apk
in your site conf,
location ~* \.(apk)$ {
add_header Content-Type application/vnd.android.package-archive;
...
}
This worked for me -
It's a known issue but easy to fix.
Login to the Web server using SSH
Verify that the apk mime doesn't exist in nginx mime.types by running:
cat /etc/nginx/mime.types
- Add apk mime type application/vnd.android.package-archive apk; into mime.types file using nano tool or vi (make sure it is inside the 'types{}')
nano /etc/nginx/mime.types
- Restart nginx service
/etc/init.d/nginx restart
I don't know how you serve the files nor what server you're using.
It might have something to do with serving the files with the correct MIME type.
The following is for Apache, but I'm sure IIS also would support adding MIME types.
Can't install APK hosted my own apache server
Please Change the MIME-TYPE mapping of apk to application/vnd.android.package-archive
How to add a MIME type to a Web site or application 1. Open Internet Information Services (IIS) Manager: o If you are using Windows Server 2008 or Windows Server 2008 R2: § On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager. o If you are using Windows Vista or Windows 7: § On the taskbar, click Start, and then click Control Panel. § Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager. 2. In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. 3. In the Home pane, double-click MIME Types.
In the MIME Types pane, click Add... in the Actions pane.
In the Add MIME Type dialog box, add the file name extension as .apk and MIME type as application/vnd.android.package-archive, and then click OK.
If You are running an Apache2 server:
- Go to /etc/apache2/mods-available
- Find file named: mime.conf
- Add this string
AddType application/vnd.android.package-archive .apk
- Save the file
- Go to /etc/apache2/mods-enabled
- Find file named: mime.conf
- Add this string
AddType application/vnd.android.package-archive .apk
- Save the file
- Restart Your server.
精彩评论