Files Versions

Introduction

The files versions API allows the following:

List File Versions

Introduction

This endpoint lists all versions of a file.

  • Path: remote.php/dav/meta/$fileid/v/

  • Method: PROPFIND

To retrieve a list of available files, use the Filter Files endpoint, and ensure that returned properties includes fileid.

Request Parameters

Attribute Type Description

fileid

integer

The file’s id.

Returns

If the file is found, then a response similar to the following is returned.

Example Response

File Is Found and Has Only One Version

If the file is found but has only one version, then a response, similar to the following, is returned, with an HTTP 207 Multi-Status status.

<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/remote.php/dav/meta/44/v/</d:href>
    <d:propstat>
      <d:prop>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>
File Is Found and Has Multiple Versions

If the file is found and has multiple versions, then a response, similar to the following, is returned, with an HTTP 207 Multi-Status status.

<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/remote.php/dav/meta/13/v/</d:href>
    <d:propstat>
      <d:prop>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/meta/13/v/1585557207</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Mon, 30 Mar 2020 08:33:27 GMT</d:getlastmodified>
        <d:getcontentlength>13313</d:getcontentlength>
        <d:resourcetype/>
        <d:getetag>"44daf1a8e9f196de0e8f8af3d5a7b6c6"</d:getetag>
        <d:getcontenttype>application/vnd.oasis.opendocument.text</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <d:quota-used-bytes/>
        <d:quota-available-bytes/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/meta/13/v/1585557036</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Mon, 30 Mar 2020 08:30:36 GMT</d:getlastmodified>
        <d:getcontentlength>13055</d:getcontentlength>
        <d:resourcetype/>
        <d:getetag>"cee399c154e4e9191a664bf4e427be39"</d:getetag>
        <d:getcontenttype>application/vnd.oasis.opendocument.text</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <d:quota-used-bytes/>
        <d:quota-available-bytes/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/meta/13/v/1585556860</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Mon, 30 Mar 2020 08:27:40 GMT</d:getlastmodified>
        <d:getcontentlength>13091</d:getcontentlength>
        <d:resourcetype/>
        <d:getetag>"03993a29446093772f771ce1f1aae555"</d:getetag>
        <d:getcontenttype>application/vnd.oasis.opendocument.text</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <d:quota-used-bytes/>
        <d:quota-available-bytes/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/meta/13/v/1584946264</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Mon, 23 Mar 2020 06:51:04 GMT</d:getlastmodified>
        <d:getcontentlength>36227</d:getcontentlength>
        <d:resourcetype/>
        <d:getetag>"807a85ee203444f3a678137156590273"</d:getetag>
        <d:getcontenttype>application/vnd.oasis.opendocument.text</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <d:quota-used-bytes/>
        <d:quota-available-bytes/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>
File Is Not Found

If the file is not found, then the following response is returned with an HTTP/1.1 404 Not Found status.

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
  <s:message/>
</d:error>

Code Example

This example retrieves versions with only the essential properties. If you want to see all properties, don’t use the --data-binary option.

  • Curl

curl --silent -v -u username:password \
  -X PROPFIND \
  -H "Content-Type: text/xml" \
  --data-binary "@search-files-with-filters.xml" \
  'https://owncloud.install.com/owncloud/remote.php/dav/meta/44/v' | xmllint --format -

search-files-with-filters.xml

<?xml version="1.0" encoding="utf-8" ?>
<a:propfind xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns">
  <a:prop>
    <oc:getcontentlength/>
    <oc:getcontenttype/>
    <oc:getetag/>
    <oc:getlastmodified/>
  </a:prop>
</a:propfind>