주 메뉴 열기

wwiki β

NextCloud Developer

Jhkim (토론 | 기여)님의 2023년 4월 5일 (수) 12:22 판 ([rfc:4918 rfc4918])

목차

Client API

Webdav

Basic APIs

WebDAV basics

base url: /remote.php/dav

모든 요청은 인증정보가 필요하다.

Testing requests with curl

WebDAV 요청은 curl로 간단하게 테스트할 수 있다.

예를 들어, 폴더에서 파일들을 찾는 요청을 할 수 있다.

$ curl -u username:password 'https://cloud.example.com/remote.php/dav/files/username/folder' -X PROPFIND --data '<?xml version="1.0" encoding="UTF-8"?>
 <d:propfind xmlns:d="DAV:">
   <d:prop xmlns:oc="http://owncloud.org/ns">
     <d:getlastmodified/>
     <d:getcontentlength/>
     <d:getcontenttype/>
     <oc:permissions/>
     <d:resourcetype/>
     <d:getetag/>
   </d:prop>
 </d:propfind>'
Listing folders
[rfc:4918 RFC4918]

폴더에 PROPFIND요청을 보내서 폴더의 컨텐츠를 리스트할 수 있다.

PROPFIND remote.php/dav/files/user/path/to/folder
Requesting properties

기본적으로 수정일시, 파일 크기, 폴더여부, eTag, mime type을 리턴한다.

PROPFIND요청을 보낼 때 추가속성을 요청할 수 있다.

<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
        <d:getlastmodified />
        <d:getetag />
        <d:getcontenttype />
        <d:resourcetype />
        <oc:fileid />
        <oc:permissions />
        <oc:size />
        <d:getcontentlength />
        <nc:has-preview />
        <oc:favorite />
        <oc:comments-unread />
        <oc:owner-display-name />
        <oc:share-types />
        <nc:contained-folder-count />
        <nc:contained-file-count />
  </d:prop>
</d:propfind>

지원되는 속성들

  • {DAV:}getlastmodified
  • {DAV:}getetag
  • {DAV:}getcontenttype
  • {DAV:}resourcetype
  • {DAV:}getcontentlength
  • {http://owncloud.org/ns}id The fileid namespaced by the instance id, globally unique
  • {http://owncloud.org/ns}fileid The unique id for the file within the instance
  • {http://owncloud.org/ns}favorite
  • {http://owncloud.org/ns}comments-href
  • {http://owncloud.org/ns}comments-count
  • {http://owncloud.org/ns}comments-unread
  • {http://owncloud.org/ns}owner-id The user id of the owner of a shared file
  • {http://owncloud.org/ns}owner-display-name The display name of the owner of a shared file
  • {http://owncloud.org/ns}share-types
  • {http://owncloud.org/ns}checksums
  • {http://nextcloud.org/ns}has-preview
  • {http://owncloud.org/ns}size Unlike getcontentlength, this property also works for folders reporting the size of everything in the folder.
  • {http://nextcloud.org/ns}rich-workspace this property is provided by the text app
  • {http://nextcloud.org/ns}contained-folder-count The number of folders directly contained in the folder (not recursively)
  • {http://nextcloud.org/ns}contained-file-count The number of files directly contained in the folder (not recursively)
Getting properties for just the folder

요청헤더에 Depth: 0 을 추가하면 폴더 컨텐츠 없이 폴더 속성을 요청할 수 있다.

Downloading files
GET remote.php/dav/files/user/path/to/file
Uploading files
PUT remote.php/dav/files/user/path/to/file
Creating folders ([rfc:4918 rfc4918])
MKCOL remote.php/dav/files/user/path/to/new/folder
Deleting files and folders ([rfc:4918 rfc4918])
DELETE remote.php/dav/files/user/path/to/file