Sunday, November 20, 2011

Python Gdata

Short version: To upload Google Docs with a service that utilizes python-gdata, use a version between 2.0.12 and 2.0.14. Keep reading for more details.

Credentiality and I spent a few hours on this tonight. Here's a brief history and a beautiful table to show you what to expect.

An SSL error occurs in a few platforms using gdata when you try to upload files to Google Docs and it doesn't appear to be limited to python-gdata. It may relate to this. Credentiality and I work on  GoogleCL sometimes, so we have all the python-gdata versions from 2.0.0 through 2.0.15 and test code with all of them, anyway. Here are some observations and what has worked for us so far.

In May 2, 2011, Google began to allow uploading "all file types" for non-premium users. Now, if you add a resumable uploader fix to a specific GoogleCL file* and you use python-gdata 2.0.10 or 2.0.12 through 2.0.14, GoogleCL should upload a PDF to Google Docs successfully.

Without the resumable uploader fix, python-gdata 2.0.10 or 2.0.12 through 2.0.14 gives us this 403 error:
403, <errors xmlns=''><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>Files must be uploaded using the resumable upload mechanism.</internalReason></error></errors>

When we use python-gdata 2.0.5 through 2.0.9 or 2.0.11, we get this 403.4 SSL error:
403, <errors xmlns=''><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>403.4 SSL required</internalReason></error></errors>

The python-gdata versions before 2.0.5 can't upload PDFs to Google Docs, anyway. We get the following error for those:
{'status': 415, 'body': 'Content-Type application/pdf is not a valid input type.', 'reason': 'Unsupported Media Type'}

python-gdata 2.0.15 doesn't work with GoogleCL to upload to Google Docs, either. Currently, we get this error, which seems to be a GoogleCL error related to some change in gdata from 2.0.14 to 2.0.15:

from import MIMETYPES
ImportError: cannot import name MIMETYPES

*In the directory: googlecl/src/googlecl/docs/ .

No comments:

Post a Comment