2

I have managed to create a simple app which deletes (bypassing the recycle bin) any files I want to. It can also upload files. The problem I am having is that I cannot specify which collection the new file should be uploaded to.

def UploadFile(folder, filename, local_file, client):
    print "Upload Resource"
    doc = gdata.docs.data.Resource(type='document', title=filename)
    path = _GetDataFilePath(local_file)
    media = gdata.data.MediaSource()
    media.SetFileHandle(path, 'application/octet-stream')
    create_uri = gdata.docs.client.RESOURCE_UPLOAD_URI + '?convert=false'
    collection_resource = folder
    upload_doc = client.CreateResource(doc, create_uri=create_uri, collection=collection_resource, media=media)
    print 'Created, and uploaded:', upload_doc.title, doc.resource_id

From what I understand the function CreateResources requires a resource object representing the collection. How do I get this object? The variable folder is currently just a string which says 'daily' which is the name of the collection, it is this variable which I need to replace with the collection resource.

4

1 回答 1

3

从各种来源,片段和一般的东西,我设法解决了这个问题。您需要将 uri 传递给 FindAllResources 函数(我在 gdata 的示例代码中没有提到该函数)。

我已经更详细地写了我是如何设法上传、删除(绕过垃圾箱)、搜索文件并将其移动到集合中的

这里

于 2012-04-11T04:12:59.477 回答