文件分类操作

创建文件分类

接口

POST https://cloud.minapp.com/userve/v1/file-category/

参数说明

Content-Type: application/json

参数 类型 必填 说明
name String Y 文件分类的名称

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.post('https://cloud.minapp.com/userve/v1/file-category/', {name: 'Category'}).then(res => {
  5. console.log(res.data)
  6. })

状态码说明

201 写入成功

获取分类详情

接口

GET https://cloud.minapp.com/userve/v1/file-category/:category_id/

其中 :category_id 需替换为你的文件分类 ID

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v1/file-category/5a1bb2ed7026d950ca7d2a78/').then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "files": 0,
  3. "id": "5a1bb2ed7026d950ca7d2a78",
  4. "name": "Category 1",
  5. "created_at": 1511761847,
  6. "parent": null,
  7. "subcategories": []
  8. }

获取文件分类列表

接口

GET https://cloud.minapp.com/userve/v1/file-category/

参数说明

Content-Type: application/json

参数 类型 必填 说明
order_by String N 排序(支持 created_at 进行排序)
limit Number N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
offset Number N 设置返回资源的起始偏移值,默认为 0

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v1/file-category/').then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "meta": {
  3. "files": 7,
  4. "limit": 20,
  5. "next": null,
  6. "offset": 0,
  7. "previous": null,
  8. "total_count": 1
  9. },
  10. "objects": [
  11. {
  12. "files": 0,
  13. "id": "5a1bb2ed7026d950ca7d2a78",
  14. "name": "Category 1",
  15. "created_at": 1511761847
  16. }
  17. ]
  18. }

字段 files 在返回中有两个地方出现;在 meta 中表示应用上传文件的数量总和;在 objects 中表示每个分类下的上传文件的数量。

修改文件分类

接口

PUT https://cloud.minapp.com/userve/v1/file-category/:category_id/

其中 :category_id 需替换为你的文件分类 ID

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.put('https://cloud.minapp.com/userve/v1/file-category/5a1bb2ed7026d950ca7d2a78/', {name: 'Category'}).then(res => {
  5. console.log(res.data)
  6. })

返回示例

  1. {
  2. "files": 0,
  3. "id": "5a1bb2ed7026d950ca7d2a78",
  4. "name": "category",
  5. "created_at": 1511761847
  6. }

状态码说明

200 修改成功

删除文件分类

接口

DELETE https://cloud.minapp.com/userve/v1/file-category/:category_id/

其中 :category_id 需替换为你的文件分类 ID

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.delete('https://cloud.minapp.com/userve/v1/file-category/5a1ba9c1fff1d651135e5ff1/').then(res => {
  5. console.log(res.data)
  6. })

状态码说明

204 删除成功