getFileSystemManager
描述
获取文件系统管理器
获取文件系统管理器,用于管理文件和目录。
因目前存在两种fakepath所以做一个区分,该协议全局生效
1. ksoxz://temp/e1f7c67d89ef4da69337ce35e66e2e04 后面为一串uuid的,命名为fakePath/uuid
2. ksoxz://user/test/1.txt 后面目录结构的,命名为fakePath/Struct
网页应用需要完成鉴权后调用该接口。
支持说明
| 客户端平台 | WPS协作版本要求 |
|---|---|
| iOS | >=5.42.0 |
| Android | >=5.42.0 |
| PC | >=5.42.0 |
输入
- 无参数
输出
| 名称 | 类型 | 描述 |
|---|---|---|
| accessFile | Function | 判断文件/目录是否存在 |
| appendFile | Function | 追加文件内容 |
| copyFile | Function | 复制文件 |
| getFile | Function | 读取本地文件内容 |
| getFileStat | Function | 获取文件状态信息 |
| getSavedFileList | Function | 读取用户目录内文件列表 |
| getStorageInfo | Function | 获取存储空间信息 |
| mkdir | Function | 创建目录 |
| openFolder | Function | 打开文件夹 |
| readdir | Function | 读取目录内容 |
| removeSavedFile | Function | 用于删除保存的本地文件 |
| rename | Function | 重命名文件 |
| saveFile | Function | 保存文件 |
| saveFileAs | Function | 保存文件到本地指定目录 |
| unlink | Function | 删除文件 |
| writeFile | Function | 写入文件 |
示例代码
ts
const manager = window.ksoxz_sdk.getFileSystemManager(
onSuccess: (msg) => {
if(msg.msg==='ok'){
成功
}
},
onError: (error) => {
console.log(error)
},)错误码
| errno | msg | 描述 |
|---|---|---|
| 1601001 | No read permission | 没有读取权限 |
| 1601002 | No write permission | 没有写入权限 |
| 1601003 | File does not exist | 文件不存在 |
| 1601004 | File already exists | 文件已存在 |
| 1601005 | Directory not empty | 目录不为空 |
| 1601006 | Is not a directory | 不是目录 |
| 1601007 | Is not a file | 不是文件 |
| 1601008 | Total size limit exceeded | 总大小超过限制 |
| 1601009 | Path and subpath operation | 路径和子路径操作 |
| 1601010 | Read size limit exceeded | 读取大小超过限制 |
| 1601011 | No encrypt or decrypt permission | 没有加密解密权限 |
| 1601012 | Write size limit exceeded | 写入大小超过限制 |
| 1601013 | Invalid file path | 无效文件路径 |
| 1601014 | File name too long | 文件名太长 |
除以上错误外,还可能存在公共错误码,参考:公共错误码