简体   繁体   English

无法从自己的网页下载和安装应用 APK

[英]Cannot download & install app APK from own webpage

I'm trying to have my apps available for download on a website, however, when I upload the APK file, it cannot be found by the browser.我试图让我的应用程序可以在网站上下载,但是,当我上传 APK 文件时,浏览器找不到它。

When zipping the APK, it is detected.压缩 APK 时,会检测到它。 However, not all phones can install from a ZIP - I have had mixed results.但是,并非所有手机都可以从 ZIP 安装 - 我的结果喜忧参半。

Why can't I simply upload an APK and have a URL point to it for a download?为什么我不能简单地上传一个 APK 并有一个指向它的 URL 来下载? Why am I getting a 404 and what can I do to avoid it?为什么我会收到 404,我该怎么做才能避免它?

Why can't I simply upload an APK and have a URL point to it for a download?为什么我不能简单地上传一个 APK 并有一个指向它的 URL 来下载?

You can.你可以。 Plenty of people do it.很多人都这样做。 There are entire Web sites dedicated to doing it, albeit usually with pirated content.有整个网站都致力于这样做,尽管通常包含盗版内容。

Why am I getting a 404为什么我收到 404

Because the URL you are entering into the browser is not the URL where the file is at on the server.因为您在浏览器中输入的 URL 不是文件在服务器上的 URL。 This is the cause of approximately 100% of 404 errors, across the Internet, regardless of circumstance.无论情况如何,这都是 Internet 上大约 100% 的 404 错误的原因。

what can I do to avoid it?我能做些什么来避免它?

Use the proper URL.使用正确的 URL。 Also, be sure to set the server's MIME type configuration map to serve up your file as application/vnd.android.package-archive .此外,请务必设置服务器的 MIME 类型配置映射,以将您的文件作为application/vnd.android.package-archive

This is what i did in my asp.net application这就是我在我的 asp.net 应用程序中所做的

My Application hosted under Window server 2008r2 having IIS 7我的应用程序托管在具有 IIS 7 的 Window server 2008r2 下

Step 1: In .aspx page add hyperlink set navigateurl as file path第 1 步:在 .aspx 页面中添加超链接,将 navigationurl 设置为文件路径

 <asp:HyperLink ID="lnkdwnload" runat="server" NavigateUrl="~/Application_Android/MyAndroidAppAame.apk">Download MyApp</asp:HyperLink>

Step 2: Web.config add mimeMap element under staticContent第二步:web.config在staticContent下添加mimeMap元素

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>

</system.webServer> </system.webServer>

in case you are using .net core,
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
...
var provider = new FileExtensionContentTypeProvider();
            // Add new mappings`enter code here`
            provider.Mappings[".apk"] = "application/octet-stream";
            app.UseStaticFiles(new StaticFileOptions()
            {
                ContentTypeProvider = provider
            });
}

Upload a web.config file in the directory where you keep the apk file在保存 apk 文件的目录中上传 web.config 文件

The content of the web.config should be : web.config 的内容应该是:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
</configuration>

Now you can download the apk file..现在你可以下载apk文件了..

Thanks it is working谢谢它正在工作

This is what i did in my asp.net application这就是我在我的 asp.net 应用程序中所做的

My Application hosted under Window server 2008r2 having IIS 7我的应用程序托管在具有 IIS 7 的 Window server 2008r2 下

Step 1: In .aspx page add hyperlink set navigateurl as file path第 1 步:在 .aspx 页面中添加超链接,将 navigationurl 设置为文件路径

<asp:HyperLink ID="lnkdwnload" runat="server" NavigateUrl="~/Application_Android/MyAndroidAppAame.apk">Download MyApp</asp:HyperLink>

Step 2: Web.config add mimeMap element under staticContent on same path第二步:Web.config 在同路径下的 staticContent 下添加 mimeMap 元素

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>

In Window Server go to IIS Manager, select your virtual directory and select MIME type在 Window Server 中,转到 IIS Manager,选择您的虚拟目录并选择 MIME 类型

Add new MIME type -> Extension "apk" Type -> "application/vnd.android.package-archive .apk"添加新的 MIME 类型 -> 扩展“apk”类型 ->“application/vnd.android.package-archive .apk”

be sure add .apk extention一定要添加 .apk 扩展名

It will enable the apk file to download from Windows Server.它将使 apk 文件能够从 Windows Server 下载。

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

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