JoeGandy / ShareX-Custom-Upload

A little PHP script created for uploading custom sharex files to your own webserver
MIT License
165 stars 50 forks source link

Override MIME type for .apk files #121

Closed davwheat closed 3 years ago

davwheat commented 3 years ago

Fixes #119


The upload server uses MIME sniffing to work out what type of file it's serving. As APKs are secret ZIP files, the MIME was being set to application/zip.

Android devices seemed to handle this badly, saving the file as xxx.apk.zip as opposed to xxx.apk.

APKs should be served with the MIME type of application/vnd.android.package-archive.

We shouldn't use octet-stream for these, because apparently this can cause issues on some devices.

Solution

I've added a new area for MIME overrides in rewrite.php. We check against the file name using regex to see if it ends with .apk. If so, we override the sniffed MIME type.

This area can be easily expanded in the future if more issues like this arise.