Avoiding content type issues when downloading a file via browser on Android
android, browser, content-disposition, content-type, download
Solution
To make any downloads work on all (and especially older) Android versions as expected, you need to...
- set the ContentType to application/octet-stream
- put the Content-Disposition filename value in double quotes
- write the Content-Disposition filename extension in UPPERCASE
Read my blog post for more details: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
Problem
If I have a file made available to a browser through my webapp, I normally just set the URL to something like `http://website.com/webapp/download/89347/image.jpg`. I then set the HTTP headers `Content-Type: application/octet-stream; filename=image.jpg` and `Content-Disposition: Attachment`. However, on the Android. It seems the only way I can get the file to download is to set `Content-Type: image/jpg`. Otherwise the file name says `<Unknown>` and an error comes Download unsuccessful Cannot download. The content is not supported on this phone Is there any way I can get Android to download and open the file through the browser without keeping a list of mime types?