3

I'm having a 403 error when trying to upload a file to Google Docs with Python / gdata-2.0.13:

import gdata.docs.data
import gdata.docs.client

client = gdata.docs.client.DocsClient(source="MyUpdater")
client.ClientLogin("mymail@gmail.com", "mykey", client.source);
client.http_client_debug = True

ms = gdata.data.MediaSource(file_path="g:/Python/Utiles/test.doc", content_type="application/msword'")
entry = client.Upload(ms, "Test File")

# Error:
gdata.client.RequestError: Server responded with: 403, <errors xmlns='http://sch
emas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenExcep
tion</code><internalReason>You do not have permission to perform this operation.
</internalReason></error></errors>
...

I tried downloading files, no problem there. I'm using a regular Gmail account (eg, no Google Apps or paid account).

Any ideas? TIA, Pablo

PabloG
  • 25,761
  • 10
  • 46
  • 59
  • http://googleappsdeveloper.blogspot.com/2011/05/upload-all-file-types-to-any-google.html this blog post indicate that you should upload using resumable upload method and pass in the ?convert=false uri parameter. let me know if you manage to get it working, I'm having loads of errors that doesn't make sense. – LZOO Sep 02 '11 at 13:04

1 Answers1

1
import gdata.docs.service
import gdata.docs.data

client = gdata.docs.service.DocsService()
client.ClientLogin("me@gmail.com", 'pass', 'test')

ms = gdata.data.MediaSource(file_path="/home/jake/Desktop/test.txt",
                            content_type=gdata.docs.service.SUPPORTED_FILETYPES['TXT'])
entry = client.Upload(ms, "Test File")
Jake
  • 2,515
  • 5
  • 26
  • 41
  • works fine for .TXT / .DOC files, thanks. Is there any way to upload other type of files, eg. ZIP? I'm getting a 415 error: "Unsupported Media Type" – PabloG Jan 06 '11 at 12:20
  • http://code.google.com/apis/documents/docs/3.0/developers_guide_python.html#UploadingArbitraryFileTypes – Jake Jan 06 '11 at 15:26