About Android package files
Android only offers to install a downloaded APK when it arrives with this type; with application/octet-stream or application/zip, some browsers save it under the wrong extension. Underneath it is a ZIP file containing AndroidManifest.xml and classes.dex.
File signature
APK files start with 50 4B 03 04 ("PK", a ZIP archive). The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .apk with the right Content-Type
Content-Type: application/vnd.android.package-archive
application/vnd.android.package-archive apk;
AddType application/vnd.android.package-archive .apk
@apk path *.apk
header @apk Content-Type "application/vnd.android.package-archive"
curl -sI https://example.com/file.apk | grep -i '^content-type'
# Content-Type: application/vnd.android.package-archive
Set the type in code
res.set('Content-Type', 'application/vnd.android.package-archive');
// Or make the browser download it:
res.attachment('file.apk');
import mimetypes
mimetypes.add_type('application/vnd.android.package-archive', '.apk') # if your system doesn't know it
mimetypes.guess_type('file.apk')[0] # 'application/vnd.android.package-archive'
mime.AddExtensionType(".apk", "application/vnd.android.package-archive")
w.Header().Set("Content-Type", "application/vnd.android.package-archive")
Accept .apk uploads
<input type="file" accept=".apk,application/vnd.android.package-archive">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
-
.zip (
application/zip): ZIP archive -
.jar (
application/java-archive): Java archive -
.exe (
application/vnd.microsoft.portable-executable): Windows executable
More programs and binaries
.bin . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .apk files?
application/vnd.android.package-archive. The full header is "Content-Type: application/vnd.android.package-archive".
Why does my server send the wrong Content-Type for .apk?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .apk is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is APK?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. APK files start with 50 4B 03 04 ("PK", a ZIP archive). The MIME type lookup on this site reads them for you when you drop a file on it.