android-play-publisher-api icon indicating copy to clipboard operation
android-play-publisher-api copied to clipboard

basic_upload_apks.py always returns googleapiclient.errors.UnknownFileType

Open klm1 opened this issue 10 years ago • 6 comments

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.

klm1 avatar Dec 31 '14 00:12 klm1

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 avatar Feb 13 '15 23:02 kevinm90

@kevinm90 -- very interesting -- definitely worth a shot!

klm1 avatar Feb 14 '15 13:02 klm1

That helped me, thanks!

lubiewegiel avatar May 28 '15 15:05 lubiewegiel

This worked for me on Linux:

    mimetypes.add_type("application/vnd.android.package-archive", ".apk")

ebridges avatar Oct 02 '15 20:10 ebridges

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.

jai-50 avatar Aug 18 '17 09:08 jai-50

For Windows also (Py2.7).

import mimetypes
...
def main():
    mimetypes.add_type("application/vnd.android.package-archive", ".apk")

meehanman avatar Jul 03 '18 10:07 meehanman