开发者

How to download ".apk" as ".apk"? (not as ".zip")

开发者 https://www.devze.com 2023-04-02 11:49 出处:网络
I have a small problem. Some browsers are not downloading the \".apk\" files correctly. How to download \".ap开发者_如何学编程k\" 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.

  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


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.

  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.


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

精彩评论

暂无评论...
验证码 换一张
取 消