文件模块 - 文件操作

优质
小牛编辑
140浏览
2023-12-01

获取文件详情

接口

GET https://cloud.minapp.com/userve/v1/file/:file_id/

其中 :file_id 需替换为你的文件 ID

代码示例

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

返回示例

  1. {
  2. "categories": [
  3. {
  4. "id": "5a1ba7b708443e7fc5f2fb18",
  5. "name": "Category",
  6. }
  7. ],
  8. "cdn_path": "1eJCS1MFGdvaaBoV.png",
  9. "created_at": 1511762369,
  10. "id": "5a1ba9c1fff1d651135e5ff1",
  11. "media_type": "image",
  12. "mime_type": "image/png",
  13. "name": "box_close.png",
  14. "path": "https://cloud-minapp-287.cloud.ifanrusercontent.com/1eJCS1MFGdvaaBoV.png",
  15. "size": 3652,
  16. "status": "success"
  17. }

获取文件列表

接口

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

参数说明

Content-Type: application/json

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

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.get('https://cloud.minapp.com/userve/v1/file/', {
  5. params: {
  6. order_by: '-created_at',
  7. category: '5a1ba7b708443e7fc5f2fb18'
  8. }
  9. }).then(res => {
  10. console.log(res.data)
  11. })

删除文件

接口

DELETE https://cloud.minapp.com/userve/v1/file/:file_id/

其中 :file_id 需替换为你的文件 ID

代码示例

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

状态码说明

204 删除成功

批量删除文件

接口

DELETE https://cloud.minapp.com/userve/v1/file/?id__in=:file1_id,:file2_id

代码示例

  1. var axios = require('axios').create({
  2. withCredentials: true
  3. })
  4. axios.delete('https://cloud.minapp.com/userve/v1/file/', {
  5. params: {
  6. id__in: '5a1ba9c1fff1d651135e5ff1,59ca3d275f281f58523fc47a'
  7. }
  8. }).then(res => {
  9. console.log(res.data)
  10. })

状态码说明

204 删除成功