22

I have a small problem. Some browsers are not downloading the ".apk" files correctly. How to download ".apk" 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".

user922907
  • 539
  • 2
  • 8
  • 18

8 Answers8

68

Create a MIME-TYPE mapping of apk to application/vnd.android.package-archive. How you do this will vary on your web server.

Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
  • please see http://stackoverflow.com/questions/28171418/download-apk-with-downloadmanager – Zuop Jan 27 '15 at 13:26
8

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>
Richard
  • 1,289
  • 12
  • 25
3

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>
keivan kashani
  • 1,263
  • 14
  • 15
2

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;
    ...
}
ifyouseewendy
  • 6,674
  • 1
  • 21
  • 26
  • I will say better to set this: `location ~ \.apk$ { add_header Content-Type application/vnd.android.package-archive; }` – nvvetal Oct 21 '16 at 12:00
2

This worked for me -

It's a known issue but easy to fix.

  1. Login to the Web server using SSH

  2. Verify that the apk mime doesn't exist in nginx mime.types by running:

cat /etc/nginx/mime.types

  1. 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

  1. Restart nginx service

/etc/init.d/nginx restart

A J
  • 4,542
  • 5
  • 50
  • 80
1

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

Community
  • 1
  • 1
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
0

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.

  1. In the MIME Types pane, click Add... in the Actions pane.

  2. 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.

Syed
  • 1
  • 1
  • 1
0

If You are running an Apache2 server:

  1. Go to /etc/apache2/mods-available
  2. Find file named: mime.conf
  3. Add this string AddType application/vnd.android.package-archive .apk
  4. Save the file
  5. Go to /etc/apache2/mods-enabled
  6. Find file named: mime.conf
  7. Add this string AddType application/vnd.android.package-archive .apk
  8. Save the file
  9. Restart Your server.