Directory contents
To get a list of files and subdirectories, specify the Depth
header in the request with the value “1”. In the response, Yandex Disk returns the directory properties along with all the items that are located at the top level of the directory.
To get a paginated list of nested elements, set the number of items to skip (the offset
parameter) and the desired number of items per page (the amount
parameter). It is assumed that the items are arranged alphabetically, and any nested directories are listed before the files.
Request for complete directory contents
The application requests properties of the Yandex Disk root directory and the items directly contained in it:
PROPFIND / HTTP/1.1 Host: webdav.yandex.ru Accept: */* Depth: 1 Authorization: OAuth 0c4181a7c2cf4521964a72ff57a34a07
The response describes all the items contained in the directory and their properties:
HTTP/1.1 207 Multi-Status Content-Type: application/xml; charset="utf-8" Content-Length: 3079 <?xml version="1.0" encoding="utf-8"?> <d:multistatus xmlns:d="DAV:"> <d:response> <d:href> / </d:href> <d:propstat> <d:status> HTTP/1.1 200 OK </d:status> <d:prop> <d:creationdate> 1970-01-01T00:00:00Z </d:creationdate> <d:displayname> disk </d:displayname> <d:getcontentlength> 0 </d:getcontentlength> <d:getlastmodified> Thu, 01 Jan 1970 00:00:00 GMT </d:getlastmodified> <d:resourcetype> <d:collection/> </d:resourcetype> </d:prop> </d:propstat> </d:response> <d:response> <d:href> /Documents/ </d:href> <d:propstat> <d:status> HTTP/1.1 200 OK </d:status> <d:prop> <d:creationdate> 2012-03-24T09:00:43Z </d:creationdate> <d:displayname> Documents </d:displayname> <d:getcontentlength> 0 </d:getcontentlength> <d:getlastmodified> Sat, 24 Mar 2012 09:00:43 GMT </d:getlastmodified> <d:resourcetype> <d:collection/> </d:resourcetype> </d:prop> </d:propstat> </d:response> <d:response> <d:href> /readme.pdf </d:href> <d:propstat> <d:status> HTTP/1.1 200 OK </d:status> <d:prop> <d:creationdate> 2012-04-09T10:56:13Z </d:creationdate> <d:displayname> readme.pdf </d:displayname> <d:getcontentlength> 455833 </d:getcontentlength> <d:getcontenttype> application/pdf </d:getcontenttype> <d:getlastmodified> Mon, 09 Apr 2012 10:56:13 GMT </d:getlastmodified> <d:resourcetype/> </d:prop> </d:propstat> </d:response> </d:multistatus>
Request for paginated directory contents
Each of the anticipated pages should contain three items.
To request the first page, just pass the amount parameter with the value “3”. To request the second page, the first three items should be skipped; to do this, set the offset parameter with the value “3”.
PROPFIND /Downloads/?offset=3&amount=3 HTTP/1.1 Host: webdav.yandex.ru Accept: */* Depth: 1 Authorization: OAuth 0c4181a7c2cf4521964a72ff57a34a07
The response shows the requested directory and three items, numbered 4, 5, and 6:
HTTP/1.1 207 Multi-Status Content-Type: application/xml; charset="utf-8" Content-Length: 1737 <?xml version="1.0" encoding="utf-8"?> <d:multistatus xmlns:d="DAV:"> <d:response> <d:href>/Downloads/</d:href> <d:propstat> <d:status>HTTP/1.1 200 OK</d:status> <d:prop> <d:resourcetype> <d:collection/> </d:resourcetype> <d:getlastmodified>Wed, 04 Apr 2012 20:00:00 GMT</d:getlastmodified> <d:getcontentlength>0</d:getcontentlength> <d:displayname>Downloads</d:displayname> <d:creationdate>2012-04-04T20:00:00Z</d:creationdate> </d:prop> </d:propstat> </d:response> <d:response> <d:href>/Downloads/Soft/</d:href> <d:propstat> <d:status>HTTP/1.1 200 OK</d:status> <d:prop> <d:resourcetype> <d:collection/> </d:resourcetype> <d:getlastmodified>Wed, 25 Jul 2012 12:23:22 GMT</d:getlastmodified> <d:getcontentlength>0</d:getcontentlength> <d:displayname>Soft</d:displayname> <d:creationdate>2012-07-25T12:23:21Z</d:creationdate> </d:prop> </d:propstat> </d:response> <d:response> <d:href>/Downloads/car.png</d:href> <d:propstat> <d:status>HTTP/1.1 200 OK</d:status> <d:prop> <d:resourcetype/> <d:getlastmodified>Wed, 25 Jul 2012 12:23:57 GMT</d:getlastmodified> <d:getcontenttype>image/png</d:getcontenttype> <d:getcontentlength>63434</d:getcontentlength> <d:displayname>car.png</d:displayname> <d:creationdate>2012-07-25T12:23:56Z</d:creationdate> </d:prop> </d:propstat> </d:response> <d:response> <d:href>/Downloads/song.mp3</d:href> <d:propstat> <d:status>HTTP/1.1 200 OK</d:status> <d:prop> <d:resourcetype/> <d:getlastmodified>Wed, 25 Jul 2012 12:23:57 GMT</d:getlastmodified> <d:getcontenttype>audio/mpeg</d:getcontenttype> <d:getcontentlength>6343431</d:getcontentlength> <d:displayname>song.mp3</d:displayname> <d:creationdate>2012-07-25T12:23:56Z</d:creationdate> </d:prop> </d:propstat> </d:response> </d:multistatus>