在root中列出文件

时间:2012-08-21 09:14:19

标签: google-drive-api google-docs-api

我正在尝试通过Google Documents API v3.0仅列出根目录中的条目。有些用户拥有数千个文件,因此通过移动数据连接请求完整供稿时间过长。

在父项中添加“q ='root”查询到文档列表请求只返回一个文件,尽管我的根目录中有很多文件。这发生在我们的REST应用程序中,可以使用OAuth2操场复制。我也尝试了各种URL编码:

https://docs.google.com/feeds/default/private/full?q='root'%20in%20parents
https://docs.google.com/feeds/default/private/full?q=%27root%27+in+parents
https://docs.google.com/feeds/default/private/full?q=%27root%20%20in%20parents

以下是OAuth2游乐场的输出:

请求:

GET /feeds/default/private/full?q='root'%20in%20parents HTTP/1.1
Host: docs.google.com
Gdata-version: 3.0
Content-length: 0
Authorization: OAuth (removed)

响应:

HTTP/1.1 200 
Gdata-version: 3.0
Content-length: 4997
Via: HTTP/1.1 GWA
Content-location: https://docs.google.com/feeds/default/private/full?q='root'%20in%20parents
X-content-type-options: nosniff
Etag: W/"AkAMSXcyfit7ImA9WhJWFU4."
Expires: Tue, 21 Aug 2012 08:46:29 GMT
Vary: Accept, X-GData-Authorization, GData-Version
X-google-cache-control: remote-fetch
Server: GSE
Last-modified: Tue, 21 Aug 2012 08:46:28 GMT
X-xss-protection: 1; mode=block
Cache-control: private, max-age=0, must-revalidate, no-transform
Date: Tue, 21 Aug 2012 08:46:29 GMT
X-frame-options: SAMEORIGIN
Content-type: application/atom+xml; charset=UTF-8; type=feed
-content-encoding: gzip
<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:docs='http://schemas.google.com/docs/2007' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;AkAMSXcyfit7ImA9WhJWFU4.&quot;'><id>https://docs.google.com/feeds/default/private/full</id><updated>2012-08-21T08:46:28.996Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#item' label='item'/><title>Available Documents - brains.for.rent@gmail.com</title><link rel='alternate' type='text/html' href='https://docs.google.com'/><link rel='http://schemas.google.com/g/2005#resumable-create-media' type='application/atom+xml' href='https://docs.google.com/feeds/upload/create-session/default/private/full'/><link rel='http://schemas.google.com/docs/2007#alt-post' type='application/atom+xml' href='https://docs.google.com/feeds/upload/file/default/private/full'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/batch'/><link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full?q=%27root%27+in+parents'/><author><name>brains.for.rent</name><email>brains.for.rent@gmail.com</email></author><openSearch:startIndex>1</openSearch:startIndex><entry gd:etag='&quot;WlEQVU5RRCt7ImBk&quot;'><id>https://docs.google.com/feeds/id/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw</id><published>2012-03-25T00:31:20.449Z</published><updated>2012-03-25T00:31:20.449Z</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-06-26T09:54:47.811Z</app:edited><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#file' label='text/plain'/><category scheme='http://schemas.google.com/g/2005/labels' term='http://schemas.google.com/g/2005/labels#modified-by-me' label='modified-by-me'/><title>_bowie.txt</title><content type='text/plain' src='https://doc-14-28-docs.googleusercontent.com/docs/securesc/jop11jq8q8326onuco763m92b29jcdfk/dh4ie9qrgpm9eub14drrse8ni0fsb4ku/1345536000000/09632875278015879870/09632875278015879870/0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw?h=16653014193614665626&amp;e=download&amp;gd=true'/><link rel='http://schemas.google.com/docs/2007#parent' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/folder%3A0B4sxUOzToIviNGNKMGZEbENRVUNrZGtNQ1ZqN3BfZw' title='conv'/><link rel='alternate' type='text/html' href='https://docs.google.com/file/d/0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw/edit'/><link rel='http://schemas.google.com/docs/2007#icon' type='image/png' href='https://ssl.gstatic.com/docs/doclist/images/icon_10_text_list.png'/><link rel='http://schemas.google.com/g/2005#resumable-edit-media' type='application/atom+xml' href='https://docs.google.com/feeds/upload/create-session/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw'/><link rel='http://schemas.google.com/docs/2007#alt-edit-media' type='application/atom+xml' href='https://docs.google.com/feeds/upload/file/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw'/><link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw'/><link rel='edit' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw'/><link rel='edit-media' type='text/plain' href='https://docs.google.com/feeds/default/media/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw'/><author><name>brains.for.rent</name><email>brains.for.rent@gmail.com</email></author><gd:resourceId>file:0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw</gd:resourceId><docs:modifiedByMeDate>2012-03-25T00:31:20.443Z</docs:modifiedByMeDate><gd:lastModifiedBy><name>brains.for.rent</name><email>brains.for.rent@gmail.com</email></gd:lastModifiedBy><gd:quotaBytesUsed>353894</gd:quotaBytesUsed><docs:writersCanInvite value='false'/><docs:md5Checksum>d9fb3e201d3dcc724d5ed5d05cf27b98</docs:md5Checksum><docs:filename>_bowie.txt</docs:filename><docs:suggestedFilename>_bowie.txt</docs:suggestedFilename><docs:size>353894</docs:size><gd:feedLink rel='http://schemas.google.com/acl/2007#accessControlList' href='https://docs.google.com/feeds/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw/acl'/><gd:feedLink rel='http://schemas.google.com/docs/2007/revisions' href='https://docs.google.com/feeds/default/private/full/file%3A0B4sxUOzToIviLUJGRkJ0VkJSTktQWTNHdWVST2gtdw/revisions'/></entry></feed>

1 个答案:

答案 0 :(得分:1)

您是否尝试过返回此集合的内容?

https://docs.google.com/feeds/default/private/full/folder%3Aroot/content

V3 DocList API可以这样说:

如果您正在寻找仅在根集合中的内容,更容易找到它们的方法是进行以下查询......

-Mike