根据我的理解,我正在开发一个适用于Google API的应用程序。如何通过Google Data API将文件上传到Google文档?
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')
有一个错误:
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'
我无法找到的方法描述文档。如何通过API将文件上传到Google文档?
@ I159我看到了您对PDF文件的评论,并相应地更新了我的答案。 – msanders