# 文件系统
# 创建文件夹
功能:创建文件夹。所有者与上级文件夹的所有者一致。
路径:fs/bs/folder/create
。
请求方法:POST
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
parentFid | 是 | string | 上级文件夹 ID,如果为顶级则传 0。 |
name | 是 | string | 文件夹名称 |
spaceType | 是 | SpaceType | 空间类型 |
appUserId | 是 | String | 业务用户 ID |
请求示例:
点击查看
export async function POST(
parentFid: string,
spaceType: SpaceType,
name: string,
appUserId: String
): Promise<ResponseBody<IflydocsDocument>> {
const method = 'POST'
const path = '/fs/bs/folder/create'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
parentFid,
spaceType,
name,
appUserId,
}
const resp = await axios.post(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": {
"status": 1,
"fid": "10tcu",
"appId": "6da37dd3",
"name": "test",
"parentFid": "0",
"createTime": 1666859323070,
"modifyTime": 1666859323070,
"creator": 1657589576821,
"creatorName": "我",
"modifier": 1657589576821,
"modifierName": "我",
"owner": 1657589576821,
"ownerName": "我",
"type": 1,
"spaceType": 1,
"collaborativeStatus": 1,
"role": "owner",
"permissions": {
"read": true,
"edit": true,
"annotate": true,
"comment": true,
"create": true,
"delete": true,
"share": true,
"export": true,
"move": true,
"copy": true,
"updateCollaborator": true,
"updateAdmin": true,
"transferSpace": true
},
"collection": false,
"top": false,
"size": 0
}
}
# 上传文件
功能:
获取上传云盘文件的临时链接。
使用临时链上传文件完成后,系统自动生成云端文件,可使用 fid
获取文件详情或者刷新列表查看文件生成情况。
文件详情中 sourceType
为 2 时表明该文件为云盘文件,sourceId
为云盘文件的 objectId
。
上传文件的实现请参考 上传示例。
下载文件接口请参考 获取下载链接。
路径:oss/bs/storage/object
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
parentFid | 是 | string | 上级文件夹 ID,如果为顶级则传 0。 |
name | 是 | string | 文件名称 |
appUserId | 是 | stirng | 创建者业务用户 ID |
desAppUserId | 是 | string | 拥有者业务用户 ID |
请求示例:
点击查看
/**
* 获取上传云盘文件的临时链接。
* @param parentFid 上级文件夹 ID,如果为顶级则传 0。
* @param name 文件名称
* @param appUserId 创建者业务用户 ID
* @param desAppUserId 拥有者业务用户 ID
* @param options 分片上传参数
*/
export async function PUT(
parentFid: string,
name: string,
appUserId: string,
desAppUserId: string,
options?:
| { partNum: '0000' }
| { partNum: string; fid: string; objectId: string }
): Promise<ResponseBody<IflydocsFileUploadInfo>> {
const method = 'PUT'
const path = '/oss/bs/storage/object'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
parentFid,
name,
appUserId,
desAppUserId,
...options,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": {
"fid": "10tdp",
"safetyChain": "https://bjbdn.openstorage.cn/v1/agji/c1/storage/9922c20d-3891-4926-b9fd-5945ac8cc52d?token=1120e32e326363efe0b79f594dbc363cc54f983e&e=1666862950",
"objectId": "storage/9922c20d-3891-4926-b9fd-5945ac8cc52d",
"requestId": "02b45c3f5bda4c7ca6eb6a2bb9600fff"
}
}
# 删除文件
功能:删除指定的文件或文件夹,文件不会被直接删除,而是会放入回收站。
路径:fs/bs/remove
。
请求方法:DELETE
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 待删除的文件 ID 列表 |
appUserId | 是 | String | 业务用户 ID |
请求示例:
点击查看
export async function DELETE(
fidList: string[],
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'DELETE'
const path = '/fs/bs/remove'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fidList,
appUserId,
}
const resp = await axios.delete(path, {
data: data,
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": null
}
# 强制删除文件
功能:强制删除文件,无法通过回收站恢复。
路径:fs/bs/delete/force
。
请求方法:DELETE
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
appUserId | 是 | string | 业务用户 ID |
fidList | 是 | string[] | 待强制删除的文件 ID 列表 |
请求示例:
点击查看
/**
* 强制删除文件,无法通过回收站恢复。
* @param appUserId 业务用户 ID
* @param fidList 文件 ID 列表
*/
export async function DELETE(
appUserId: string,
fidList: string[]
): Promise<ResponseBody<null>> {
const method = 'DELETE'
const path = '/fs/bs/delete/force'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
appUserId,
fidList,
}
const resp = await axios.delete(path, {
data: data,
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": null
}
# 重命名文件
功能:修改文件或文件夹的名称。
路径:fs/bs/updateName
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
name | 是 | string | 文件名称 |
appUserId | 是 | String | 业务用户 ID |
请求示例:
点击查看
export async function POST(
fid: string,
name: string,
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'PUT'
const path = '/fs/bs/updateName'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fid,
name,
appUserId,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": null
}
# 获取文件详情
功能:
获取文件详情,包含 fs/bs/metadata
接口设置的元数据。
注意
元数据仅能通过此接口获取。
路径:fs/bs/fsFile
。
请求方法:GET
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
appUserId | 是 | String | 业务用户 ID |
请求示例:
点击查看
/**
* 获取文件详情
* 可获取 `fs/bs/metadata` 接口设置的元数据。
* 注意:元数据仅能通过此接口获取。
* @param fid 文件 ID
* @param uid 文档用户 ID
*/
export async function GET(
fid: string,
appUserId: string
): Promise<ResponseBody<IflydocsDocument & IflydocsFileSize>> {
const method = 'GET'
const path = '/fs/bs/fsFile'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fid,
appUserId,
}
const resp = await axios.get(path, {
params,
paramsSerializer: (params) => qs.stringify(params),
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": {
"status": 1,
"metadata": {
"priority": 60,
"assign": "junmei"
},
"fid": "10tcM",
"appId": "6da37dd3",
"name": "test-fsfile",
"parentFid": "0",
"createTime": 1666859326772,
"modifyTime": 1666859326772,
"creator": 1657589576821,
"creatorName": "我",
"modifier": 1657589576821,
"modifierName": "我",
"owner": 1657589576821,
"ownerName": "我",
"docType": "note",
"type": 2,
"sourceType": 1,
"sourceId": "10tcM",
"suffix": "note",
"fileType": 1,
"spaceType": 1,
"collaborativeStatus": 1,
"role": "owner",
"permissions": {
"read": true,
"edit": true,
"annotate": true,
"comment": true,
"create": true,
"delete": true,
"share": true,
"export": true,
"move": true,
"copy": true,
"updateCollaborator": true,
"updateAdmin": true,
"transferSpace": true
},
"collection": false,
"top": false,
"size": 0
}
}
# 获取文件大小
功能:
获取文件或文件夹的大小。
对于文件夹,统计文件夹下所有正常状态文件大小的总和,不包含回收站。
路径:fs/bs/file/size
。
请求方法:GET
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 文件 ID 列表 |
请求示例:
点击查看
/**
* 获取文件或文件夹的大小
* 对于文件夹,统计文件夹下所有正常状态文件大小的总和,不包含回收站。
* @param fidList 文件 ID 列表
*/
export async function GET(
fidList: string[]
): Promise<ResponseBody<{ fid: string; size: number }[]>> {
const method = 'GET'
const path = '/fs/bs/file/size'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fidList,
}
const resp = await axios.get(path, {
headers,
params,
paramsSerializer: (params) => qs.stringify(params),
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": [
{
"fid": "10tct",
"size": 0
}
]
}
# 设置文件元数据
功能:
设置或更新(覆盖)文件的元数据。
文件元数据可以存储业务有关的自定义数据。设置后,可通过 fs/bs/fsFile
接口获取。
路径:fs/bs/metadata
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
metadata | 是 | Object | 元数据 Key-Value 对象 |
参数示例:
{
"fid": "10Pd",
"metadata": { "test": "note" }
}
请求示例:
点击查看
/**
* 设置或更新(覆盖)文件的元数据
* 文件元数据可以存储业务有关的自定义数据。
* 设置后,可通过 `fs/bs/fsFile` 接口获取。
* @param fid 文件 ID
* @param metadata 文件元数据
*/
export async function PUT(
fid: string,
metadata: Record<string, any> | null
): Promise<ResponseBody<null>> {
const method = 'PUT'
const path = '/fs/bs/metadata'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fid,
metadata,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": null
}
# 可创建副本的文件夹
功能:查询副本可创建到的文件夹树状数据。
路径:fs/bs/copy/folderTree
。
请求方法:GET
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
appUserId | 是 | string | 业务用户 ID |
请求示例:
点击查看
type FolderTree = {
/** 与我协作的 */
col: IflydocsDocument[]
/** 我的空间 */
mySpace: IflydocsDocument[]
/** 父目录 */
parent: IflydocsDocument
}
/**
* 查询副本可创建到的文件夹树状
* 个人空间或者他人协作给当前用户的文件夹中,用户有创建权限的文件夹树状列表。
* @param fid 文件(夹)ID
* @param appUserId 业务用户 ID
*/
export async function GET(
fid: string,
appUserId: string
): Promise<ResponseBody<FolderTree>> {
const method = 'GET'
const path = '/fs/bs/copy/folderTree'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fid,
appUserId,
}
const resp = await axios.get(path, {
headers,
params,
paramsSerializer: (params) => qs.stringify(params),
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": {
"parent": {
"parentFid": "0",
"fid": "10tc4",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
"col": [],
"mySpace": [
{
"parentFid": "0",
"fid": "10tc4",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tc4",
"fid": "10tc5",
"name": "2",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
},
{
"parentFid": "0",
"fid": "10tc0",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tc0",
"fid": "10tc1",
"name": "2",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
},
{
"parentFid": "0",
"fid": "10tbS",
"name": "a",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tbS",
"fid": "10tbT",
"name": "b",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tbT",
"fid": "10tbU",
"name": "c",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
}
]
}
]
}
}
# 创建文件副本
功能:
创建文件的副本。
支持文件夹,文件夹会递归地拷贝子文件。
创建文件副本是异步的,需要轮询 fs/bs/copy/result
接口获取结果。
提示
支持跨用户拷贝,可以通过此接口实现文件提取、转存等功能。
路径:fs/bs/copy
。
请求方法:POST
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
parentFid | 是 | string | 上级文件夹 ID |
desAppUserId | 是 | string | 业务用户 ID |
addMetadata | 否 | boolean | 是否拷贝文件元数据,默认不拷贝 |
desFileName | 否 | string | 拷贝到的文件名称,默认与原文件同名 |
参数示例:
{
"desAppUserId": "006",
"fid": "xx",
"parentFid": "0",
"addMetadata": true,
"desFileName": "副本文件名"
}
请求示例:
点击查看
/**
* 创建文件(夹)的副本,需要轮询 `fs/bs/copy/result` 接口获取拷贝结果。
* @param fid 文件 ID
* @param parentFid 目标文件夹 ID
* @param desAppUserId 目标业务用户 ID
* @param addMetadata 是否拷贝文件元数据,默认 false 不拷贝
* @param desFileName 目标文件名,默认与原文件一致
*/
export async function POST(
fid: string,
parentFid: string,
desAppUserId: string,
addMetadata?: false,
desFileName?: string
): Promise<ResponseBody<IflydocsCopyProcess>> {
const method = 'POST'
const path = '/fs/bs/copy'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
desAppUserId,
fid,
parentFid,
addMetadata,
desFileName,
}
const resp = await axios.post(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": {
"uid": 1657589576821,
"sourceFid": "10tc2",
"desFid": null,
"requestId": "5c53615c92f1483aa75ce994ec1ef2db",
"requestTime": 1666859291804,
"startProcessTime": 1666859291804,
"overProcessTime": null,
"status": 2,
"message": null
}
}
# 查询创建副本结果
功能:查询创建副本结果。
路径:fs/bs/copy/result
。
请求方法:GET
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
requestId | 是 | string | 创建文件副本请求 ID |
fid | 是 | string | 文件 ID |
请求示例:
点击查看
/**
* 查询创建副本的结果
* 需要轮询。
* @param requestId 创建副本请求 ID
* @param fid 源文件 ID
*/
export async function GET(
requestId: string,
fid: string
): Promise<
ResponseBody<{
process: IflydocsImportProcess
detail: IflydocsDocument
}>
> {
const method = 'GET'
const path = '/fs/bs/copy/result'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
requestId,
fid,
}
const resp = await axios.get(path, {
headers,
params,
paramsSerializer: (params) => qs.stringify(params),
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "副本已创建",
"data": {
"process": {
"uid": 1657589576821,
"sourceFid": "10tc2",
"desFid": "10tc3",
"requestId": "5c53615c92f1483aa75ce994ec1ef2db",
"requestTime": 1666859291804,
"startProcessTime": 1666859291804,
"overProcessTime": 1666859291924,
"status": 3,
"message": "副本已创建"
},
"detail": {
"status": 1,
"fid": "10tc3",
"appId": "6da37dd3",
"name": "3",
"parentFid": "10tc1",
"createTime": 1666859291824,
"modifyTime": 1666859291824,
"creator": 1657589576821,
"creatorName": "我",
"modifier": 1657589576821,
"modifierName": "我",
"owner": 1657589576821,
"ownerName": "我",
"docType": "note",
"type": 2,
"sourceType": 1,
"sourceId": "10tc3",
"suffix": "note",
"fileType": 1,
"spaceType": 1,
"collaborativeStatus": 1,
"role": "owner",
"permissions": {
"read": true,
"edit": true,
"annotate": true,
"comment": true,
"create": true,
"delete": true,
"share": true,
"export": true,
"move": true,
"copy": true,
"updateCollaborator": true,
"updateAdmin": true,
"transferSpace": true
},
"collection": false,
"top": false,
"size": 0
}
}
}
# 查询可移动到的文件夹
功能:查询可移动到的文件夹树状数据。
路径:fs/bs/move/folderTree
。
请求方法:GET
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
appUserId | 是 | String | 业务用户 ID |
请求示例:
点击查看
type FolderNode = IflydocsDocument & { childs: FolderNode[] }
/**
* 查询可移动到的文件夹树状
* TODO: 具体逻辑是什么?
* @param fid 文件(夹)ID
* @param uid 用户 ID
*/
export async function GET(
fid: string,
appUserId: string
): Promise<ResponseBody<FolderNode[]>> {
const method = 'GET'
const path = '/fs/bs/move/folderTree'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fid,
appUserId,
}
const resp = await axios.get(path, {
headers,
params,
paramsSerializer: (params) => qs.stringify(params),
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": [
{
"parentFid": "0",
"fid": "0",
"name": "我所有的",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "0",
"fid": "10td3",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10td3",
"fid": "10td4",
"name": "2",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
},
{
"parentFid": "0",
"fid": "10td2",
"name": "test-move-folder",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcU",
"name": "test",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcN",
"name": "filter_by_name",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcK",
"name": "👨💻❤️",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcJ",
"name": "🍻😁",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcI",
"name": "干杯",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcH",
"name": "SELECT * from",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcG",
"name": "3a=",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcF",
"name": "a/b",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcv",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcv",
"fid": "10tcw",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcw",
"fid": "10tcx",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcx",
"fid": "10tcy",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcy",
"fid": "10tcz",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcz",
"fid": "10tcA",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcA",
"fid": "10tcB",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcB",
"fid": "10tcC",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcC",
"fid": "10tcD",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tcD",
"fid": "10tcE",
"name": "test-@{i+1}",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"parentFid": "0",
"fid": "10tcu",
"name": "test",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tcs",
"name": "test-size-folder",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tc8",
"name": "test-doc-create",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
},
{
"parentFid": "0",
"fid": "10tc4",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tc4",
"fid": "10tc5",
"name": "2",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
},
{
"parentFid": "0",
"fid": "10tc0",
"name": "1",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tc0",
"fid": "10tc1",
"name": "2",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
},
{
"parentFid": "0",
"fid": "10tbS",
"name": "a",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tbS",
"fid": "10tbT",
"name": "b",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": [
{
"parentFid": "10tbT",
"fid": "10tbU",
"name": "c",
"ownerAppUserId": "dev-docs-001",
"ownerName": "",
"childs": []
}
]
}
]
}
]
}
]
}
# 移动文件
功能:移动文件或文件夹到目标文件夹。
路径:fs/bs/move
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fid | 是 | string | 文件 ID |
parentFid | 是 | string | 目标文件夹 ID |
请求示例:
点击查看
/**
* 移动文件(夹)到目标文件夹
* @param fid 源(待移动)文件 ID
* @param parentFid 目标文件夹 ID
* @param appUserId 业务用户 ID
*/
export async function PUT(
fid: string,
parentFid: string,
appUserId: string
): Promise<ResponseBody<IflydocsDocument>> {
const method = 'PUT'
const path = '/fs/bs/move'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fid,
parentFid,
appUserId,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "已成功移动",
"data": {
"status": 1,
"fid": "10td1",
"appId": "6da37dd3",
"name": "test-move-file",
"parentFid": "10td2",
"createTime": 1666859336851,
"modifyTime": 1666859336851,
"creator": 1657589576821,
"creatorName": "我",
"modifier": 1657589576821,
"modifierName": "我",
"owner": 1657589576821,
"ownerName": "我",
"docType": "note",
"type": 2,
"sourceType": 1,
"sourceId": "10td1",
"suffix": "note",
"fileType": 1,
"spaceType": 1,
"collaborativeStatus": 1,
"role": "owner",
"permissions": {
"read": true,
"edit": true,
"annotate": true,
"comment": true,
"create": true,
"delete": true,
"share": true,
"export": true,
"move": true,
"copy": true,
"updateCollaborator": true,
"updateAdmin": true,
"transferSpace": true
},
"collection": false,
"top": false,
"size": 0
}
}
# 收藏文件
功能:收藏文件或文件夹(或添加星标、爱心等)。
注意
对于协作文件,收藏仅对当前操作用户有效。
路径:fs/bs/collect
。
请求方法:POST
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 文件 ID 列表 |
appUserId | 是 | string | 业务用户 ID |
请求示例:
点击查看
/**
* 收藏文件(夹)
* 添加星标。
* @param fidList 文件 ID 列表
* @param appUserId 业务用户 ID
*/
export async function POST(
fidList: string[],
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'POST'
const path = '/fs/bs/collect'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fidList,
appUserId,
}
const resp = await axios.post(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "收藏成功",
"data": null
}
# 取消收藏
功能:取消收藏文件或文件夹。
路径:fs/bs/collect
。
请求方法:DELETE
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 文件 ID 列表 |
appUserId | 是 | string | 业务用户 ID |
请求示例:
点击查看
/**
* 取消收藏文件(夹)
* 移除星标。
* @param fidList 文件 ID 列表
* @param appUserId 业务用户 ID
*/
export async function DELETE(
fidList: string[],
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'DELETE'
const path = '/fs/bs/collect'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fidList,
appUserId,
}
const resp = await axios.delete(path, {
data: params,
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "取消收藏成功",
"data": null
}
# 置顶文件
功能:将文件或文件夹置顶,将会影响文件列表接口返回结果的排序。
注意
对于协作文件,置顶仅对当前操作用户有效。
路径:fs/bs/top
。
请求方法:POST
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 文件 ID 列表 |
appUserId | 是 | string | 业务用户 ID |
请求示例:
点击查看
/**
* 将文件(夹)置顶
* NOTE: 对于协作文件夹,置顶仅对个人生效。
* @param fidList 文件 ID 列表
* @param appUserId 业务用户 ID
*/
export async function POST(
fidList: string[],
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'POST'
const path = '/fs/bs/top'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
fidList,
appUserId,
}
const resp = await axios.post(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "置顶成功",
"data": null
}
# 取消置顶
功能:将文件或文件夹取消置顶。
路径:fs/bs/top
。
请求方法:DELETE
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
fidList | 是 | string[] | 文件 ID 列表 |
appUserId | 是 | string | 业务用户 ID |
请求示例:
点击查看
/**
* 取消文件(夹)置顶
* NOTE: 对于协作文件夹,置顶仅对个人生效。
* @param fidList 文件 ID 列表
* @param appUserId 业务用户 ID
*/
export async function DELETE(
fidList: string[],
appUserId: string
): Promise<ResponseBody<null>> {
const method = 'DELETE'
const path = '/fs/bs/top'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const params = {
fidList,
appUserId,
}
const resp = await axios.delete(path, {
data: params,
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "取消置顶成功",
"data": null
}
# 转让空间、文件夹
功能:转让空间、文件夹到其他用户空间或文件夹下。
路径:fs/bs/space/transfer
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
sourceAppUserId | 是 | string | 空间、文件夹原所有者 |
sourceFid | 是 | string | 待转让空间、文件夹 ID ,空间 ID 为 0 |
desParentFid | 是 | string | 转让到的空间、文件夹 ID ,空间 ID 为 0 |
saveCollaboration | 是 | boolean | 是否保留原文件夹、空间及其子孙文件的协作关系 |
appUserId | 是 | string | 转让到的空间、文件夹所有者,业务用户 ID |
请求示例:
点击查看
/**
* 转让空间、文件夹到其他用户空间、文件夹,空间 ID 为 0。
* @param sourceAppUserId 空间、文件夹当前业务用户ID
* @param sourceFid 转让空间、文件夹 ID
* @param desParentFid 转让到空间、文件夹 ID
* @param desAppUserId 转让到业务用户 ID
* @param saveCollaboration 是否保留协作关系
*/
export async function PUT(
sourceFid: string,
sourceAppUserId: string,
desParentFid: string,
desAppUserId: string,
saveCollaboration: boolean
): Promise<ResponseBody<null>> {
const method = 'PUT'
const path = '/fs/bs/space/transfer'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
sourceAppUserId,
sourceFid,
desParentFid,
desAppUserId,
saveCollaboration,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
响应示例:
点击查看
{
"code": 0,
"message": "success",
"data": null
}
# 清空空间、文件夹
功能:清空用户空间、文件夹。
路径:fs/bs/space/empty
。
请求方法:PUT
。
请求参数:
参数 | 必须 | 类型 | 备注 |
---|---|---|---|
parentFid | 是 | string | 清空的空间、文件夹 ID ,空间 ID 为 0 |
appUserId | 是 | string | 清空的空间、文件夹所有者,业务用户 ID |
请求示例:
点击查看
import axios from 'axios'
import genNonce from '@src/nonce'
import sign from '@src/sign'
import authorization from '@src/authorization'
import { ResponseBody } from '@src/response'
//#region put
/**
* 转让空间、文件夹到其他用户空间、文件夹,空间 ID 为 0。
* @param sourceAppUserId 空间、文件夹当前业务用户ID
* @param sourceFid 转让空间、文件夹 ID
* @param desParentFid 转让到空间、文件夹 ID
* @param desAppUserId 转让到业务用户 ID
* @param saveCollaboration 是否保留协作关系
*/
export async function PUT(
sourceFid: string,
sourceAppUserId: string,
desParentFid: string,
desAppUserId: string,
saveCollaboration: boolean
): Promise<ResponseBody<null>> {
const method = 'PUT'
const path = '/fs/bs/space/transfer'
const { nonce, timestamp } = genNonce()
const signature = sign(method, path, nonce, timestamp)
const Authorization = authorization(signature)
const headers = {
Authorization,
nonce,
timestamp,
}
const data = {
sourceAppUserId,
sourceFid,
desParentFid,
desAppUserId,
saveCollaboration,
}
const resp = await axios.put(path, data, {
headers,
})
return resp.data
}
//#endregion put
响应示例:
点击查看
```jsonc
//#region put
{
"code": 0,
"message": "success",
"data": null
}
//#endregion put
```