I developing an application which works with Google API, according to my understanding.
def push_to_ga(request):
client = gdata.docs.service.DocsService()
client.ClientLogin('[email protected]', 'password')
entrys = Entry.objects.all()
for entry in entrys:
splitted = entry.file.split('/')
client.UploadDocument(entry.file, splitted[-1])
return HttpResponseRedirect('https://docs.google.com/#home')
Have an error:
Traceback: File "/home/i159/Env/googleapi/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/home/i159/workspace/apiroot/googleapi/../googleapi/apiapp/views.py" in push_to_ga 38. client.UploadDocument(entry.file, 'My entry #' + str(entry.id)) File "/home/i159/Env/googleapi/lib/python2.6/site-packages/atom/init.py" in deprecated_function 1475. return f(*args, **kwargs) File "/home/i159/Env/googleapi/lib/python2.6/site-packages/gdata/docs/service.py" in UploadDocument 494. folder_or_uri=folder_or_uri) File "/home/i159/Env/googleapi/lib/python2.6/site-packages/gdata/docs/service.py" in _UploadFile 160. extra_headers={'Slug': media_source.file_name},
Exception Type: AttributeError at /push_to_ga/ Exception Value: 'unicode' object has no attribute 'file_name'
I can't find docs with description of the methods. How to upload file into Google Docs through API?