APK download failure if behind password protected site on stock browser
android, ruby-on-rails
Solution
This looks to be a (~6-year old!!) bug in Android: https://code.google.com/p/android/issues/detail?id=1353
Apparently all we can do is star the issue. There are other hacky workarounds posted around the internet that you can find on your own, but I wouldn't recommend most of them as a general solution.
Perhaps try changing the filename extension to be in all caps, as suggested here: http://www.digiblog.de/2011/04/android-and-the-download-file-headers/
So the line becomes:
`Content-Disposition: attachment; filename="SironaVideoSurvey.APK"`
If that doesn't work, I would just recommend that you tell your clients to use a different, non-stock (and non-Chrome!) browser. :/ Good luck.
Problem
I'm having an issue serving an APK on my server that is using rails. I can serve the APK if the download link is put in /public. However, I want to password protect it. If I move the file behind a URL that requires HTTP authentication, then it will fail on the stock browser with a `Download Unsuccessful` immediately. If I install and run firefox, firefox is able to download the APK and install correctly. Anyone know how to make this work with Android's stock browser? I have added the `MIME Type` to the server: ``` Mime::Type.register "application/vnd.android.package-archive", :apk ``` And I'm trying to send_file while behind HTTP authentication: ``` send_file "android.apk", :type => 'application/vnd.android.package-archive' ``` Successful HTTP-header from /public: ``` ~ curl -s -D- android.apk -o/dev/null HTTP/1.1 200 OK Server: nginx/1.4.1 Date: Thu, 11 Jul 2013 20:06:43 GMT Content-Type: application/octet-stream Content-Length: 38673086 Last-Modified: Thu, 11 Jul 2013 20:05:12 GMT Connection: keep-alive ETag: "51df0ff8-24e1abe" Accept-Ranges: bytes ``` Unsuccessful HTTP header from behind HTTP Authentication: ``` ~ curl -s -D- private/android.apk -o/dev/null HTTP/1.1 200 OK Server: nginx/1.4.1 Date: Thu, 11 Jul 2013 20:11:53 GMT Content-Type: application/octet-stream Transfer-Encoding: chunked Connection: keep-alive Status: 200 OK X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-UA-Compatible: chrome=1 Content-Disposition: attachment; filename="SironaVideoSurvey.apk" Content-Transfer-Encoding: binary Cache-Control: private Set-Cookie: request_method=GET; path=/ X-Request-Id: 6b99f5e5-87f8-4f8c-816c-0034265b3991 X-Runtime: 0.016140 ```