5

I'm trying to upload a backup file from my server to my Google storage in a Python script. The backup file is an encrypted zip file (gpg file). It connects successfully, but fails transferring the file which the following error:

Traceback (most recent call last):
  File "backup.py", line 37, in <module>
    entry = gd_client.Upload(ms, 'Backup.gpg', folder_or_uri=uri)
  File "/usr/local/lib/python2.6/dist-packages/gdata/docs/service.py", line 306, in Upload
    folder_or_uri)
  File "/usr/local/lib/python2.6/dist-packages/gdata/docs/service.py", line 161, in _UploadFile
    converter=gdata.docs.DocumentListEntryFromString)
  File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 1358, in PostOrPut
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'}

Here is my code:

import os
import sys
import gdata.docs
import gdata.docs.service
import gdata.docs.client

gd_client = gdata.docs.service.DocsService()
gd_client.ClientLogin('[email protected]', 'mypassword')

uri = '%s?convert=false' % gdata.docs.client.DOCLIST_FEED_URI

f = open('backup.zip.gpg')
ms = gdata.MediaSource(file_handle=f, content_type='application/octet-stream', content_length=os.path.getsize(f.name))
entry = gd_client.Upload(ms, 'Backup.gpg', folder_or_uri=uri)

It's possible that the file is just too big (56mb), and I can't use Google Docs storage this way. I'd hope for a more explicit error message if this was the case though. I'm wondering if it's a problem with my saying 'convert=false'. It's a Google Apps account that I'm using.

4
  • 1
    If you think that the problem is of size being too big, why don't you try to break your zip file into smaller, say 5mb, files and then try to upload them? Commented Jul 13, 2011 at 13:15
  • Unfortunately this still produced the same error Commented Jul 13, 2011 at 19:28
  • 1
    Is this a Google Apps for Business account? Commented Jul 14, 2011 at 2:07
  • Ah, I had thought it was, but just checked and it's just a standard Google Apps account. That explains it then :( I guess I'll look for an alternative storage solution instead. I was just hoping to take advantage of the 20gig storage space I had there! Feel free to post this as an answer so you get the rep. Commented Jul 14, 2011 at 12:53

2 Answers 2

2

Uploading files of any type are only allowed for Google Apps for Business accounts. A regular account cannot upload this filetype. See this link from the Google Docs API.

Sign up to request clarification or add additional context in comments.

Comments

2

Good news: now Google Apps for Free accounts can also upload files of any type.

Three key points here:

To see an example in python, please go to download gdata-2.0.14 and find resumable_upload_sample.py under the directory samples/docs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.