1. **Webdav**
Basic APIs
- WebDAV basics
基础url:/remote.php/dav
所有的请求都需要进行身份验证(Auth header 或者 有效的session cookies)
- Testing requests with url
webdav请求:curl GET/PROPFIND/PUT
例:通过propfind请求查找文件
```bash
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
列出文件夹内容
```bash
PROPFIND remote.php/dav/files/user/path/to/folder
```
通过修改请求内容获取文件属性
```xml
<?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>
```
- Downloading files
下载文件
```bash
GET remote.php/dav/files/user/path/to/file
```
- Uploading files
上传文件
```bash
PUT remote.php/dav/files/user/path/to/file
```
- Creating folders
创建文件夹
```bash
MKCOL remote.php/dav/files/user/path/to/new/folder
```
- Deleting files and folders
删除文件或文件夹,当删除文件夹时,其内容将会递归删除
```bash
DELETE remote.php/dav/files/user/path/to/file
```
- Moving files and folders
移动文件或文件夹
```bash
MOVE remote.php/dav/files/user/path/to/file
Destination: https://cloud.example/remote.php/dav/files/user/new/location
```
- Copying files and folders
复制文件和文件夹
```bash
COPY remote.php/dav/files/user/path/to/file
Destination: https://cloud.example/remote.php/dav/files/user/new/location
```
- Setting favorites
设置收藏
```bash
PROPPATCH remote.php/dav/files/user/path/to/file
<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:set>
<d:prop>
<oc:favorite>1</oc:favorite>
</d:prop>
</d:set>
</d:propertyupdate>
```
通过设置oc:favorite属性标记是否为收藏
- Listing favorites
列出收藏夹
```bash
REPORT remote.php/dav/files/user/path/to/folder
<?xml version="1.0"?>
<oc:filter-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
<oc:filter-rules>
<oc:favorite>1</oc:favorite>
</oc:filter-rules>
</oc:filter-files>
```
Search
- Making search requests
搜索请求:SEARC Hhttps://cloud.example.com/remote.php/dav /text/xml
例如:搜索test文件
```bash
curl -u test:password 'https://cloud.example.com/remote.php/dav/' -X SEARCH -H "content-Type: text/xml" --data '<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<oc:fileid/>
<d:displayname/>
<d:getcontenttype/>
<d:getetag/>
<oc:size/>
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/test</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:like>
<d:prop>
<d:getcontenttype/>
</d:prop>
<d:literal>text/%</d:literal>
</d:like>
</d:where>
<d:orderby/>
</d:basicsearch>
</d:searchrequest>'
```
搜索范围为dav根目录的相对路径
- Examples search bodies
搜索超过10MB的png、jpg图片
```bash
<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<d:displayname/>
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/test</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:and>
<d:or>
<d:eq>
<d:prop>
<d:getcontenttype/>
</d:prop>
<d:literal>image/png</d:literal>
</d:eq>
<d:eq>
<d:prop>
<d:getcontenttype/>
</d:prop>
<d:literal>image/jpg</d:literal>
</d:eq>
</d:or>
<d:gt>
<d:prop>
<oc:size/>
</d:prop>
<d:literal>10000000</d:literal>
</d:gt>
</d:and>
</d:where>
<d:orderby/>
</d:basicsearch>
</d:searchrequest>
```
Trashbin
- Listing the trashbin content
- Restoring from the trashbin
- Deleting from the trashbin
- Emptying the trashbin
Versions
- Listing the version of a file
- Restoring a version
Chunked file upload
- Introduction
- Usage
File bulk upload
- Introduction
- Usage
Comments
- Endpoint
---
2. **OCS API**
OCS APIs overview
- Testing requests with curl
- User metadata
- User metadata - List user IDs
- Capabilities API
- Theming capabilities
- Direct Download
- Notifications
- Auto-compelte and user-search
OCS Share API
- Local Shares
- Federated Cloud Shares
OCS Sharee API
- Search
- Recommendation
OCS Status API
- User Status - Status Manipulation
- User Status - Predefined statuses
- User Status - Retrieve statuses
OCS Recommendations API
- Recommendation - Retrieval
OCS user preferences API
- Setting a preference
- Setting multiple preference
- Deleting a preference
- Deleting multiple preference
OCS Translation API
- Get available translation options
- Translate a string
---
3. **Login Flow**
Opening the webview
Login in the user
Obtaining the login credentials
Converting to app passwords
Deleting an app password
Login flow v2
Troubleshooting
- Login name vs. email login
---
4. **Remote wipe**
Obtaining wipe status
Wiping the actual device
Signalling completion