android-play-publisher-api
android-play-publisher-api copied to clipboard
basic_upload_apks.py always returns googleapiclient.errors.UnknownFileType
The sample basic_upload_apks.py when run like this:
python basic_upload_apks.py com.company.appname appname.apk
always returns
"googleapiclient.errors.UnknownFileType: appname.apk"
I believe this is because createMethod()
in discovery.py raises an exception if the guessed MIME type is None -- which it seems it always would be.
I experienced the same error and solved this by adding the Mime-Type to the windows registry (assuming you experienced this error on windows aswell): ◾go to regedit.exe ◾go to HKEY_LOCAL_MACHINE\Software\Classes ◾right click Classes, New Key - call it .apk ◾right click on the right hand side, New String - "Content Type", "application/vnd.android.package-archive"
@kevinm90 -- very interesting -- definitely worth a shot!
That helped me, thanks!
This worked for me on Linux:
mimetypes.add_type("application/vnd.android.package-archive", ".apk")
This was really useful for me and helped solve my issues, thanks all! Some more information:
For expansion files on Windows I repeated @kevinm90 's answer for .obb using "Content Type", "application/octet-stream".
If you're uploading from a Mac then you may have to edit a mime.types file to define apk/obb types. Where this file is depends on your setup but for me it was at /etc/apache2/. The mimetypes.py script in your Python Lib directory should contain a variable with a list of 'knownfiles' you can try to locate to figure out where your MIME types are being defined for upload.
For Windows also (Py2.7).
import mimetypes
...
def main():
mimetypes.add_type("application/vnd.android.package-archive", ".apk")