nextcloud API接口

本文详细介绍了如何使用WebDAV基本API执行文件操作,如上传、下载、删除、移动和复制文件,以及设置收藏和搜索文件。同时,文章还涵盖了OCSAPI的不同方面,包括用户元数据、共享、状态管理和推荐功能。此外,提到了登录流程和远程擦除设备的相关信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
 

python selenium自动化(一)点击页面链接测试 - harolei - 博客园 (cnblogs.com)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值