在我的 Goggle App Engine 应用程序中使用 Python gdata 我试图复制一个谷歌文档资源并将副本放在与源文件相同的文件夹中。我使用的CopyResource
方法将副本放在根级别。
您知道如何查询 Google Docs 以获取文件所在的文件夹/集合列表吗?
import gdata.docs.service
import gdata.docs.client
...
doc_service = gdata.docs.client.DocsClient()
doc_service.ClientLogin('username', 'abc123', 'my app name')
try:
doc = doc_service.GetResourceById(resourceId)
newdoc = doc_service.CopyResource(doc, filename)
# newdoc is copied at the root level of Google Drive
# need to move it where the source file is located.
newdocid = newdoc.id.text.decode('utf-8').split('%3A')[1]
# would like here to have my newly copied document
# moved to the same directory as the source one.
# assuming the source is only in one folder.
except gdata.client.RequestError, inst:
logging.info('Copy Error: %s', inst.body)