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
curl
or something to dump the HTTP headers of a successful request? I suspect that those headers may give us some clues. For example, if the headers includeContent-Disposition: Attachment
, you may need to make some adjustments to what you are serving: stackoverflow.com/questions/4674737/…