# FileSystemManager.saveFile
保存临时文件到本地永久目录
该 API 会把临时文件移动到永久目录(目录最大200M),所以在调用成功后原文件路径将访问失败
# 支持说明
应用能力 | Android | iOS | PC | 预览效果 |
---|---|---|---|---|
小程序 | 3.12.0 | 3.11.0 | 3.10.0 | 扫码预览 用BoosHi扫码或PC端点击 |
网页应用 | 待开发 | 待开发 | 待开发 | 待补充 |
# 输入
继承标准对象输入,扩展属性描述:
名称 | 数据类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
tempFilePath | string | 是 | 文件临时路径 示例值:bzfile://temp/5c5fdd01-03bd-42cf-9938-31fb8b769a19-2863810ed1844e79f1b9bb880acb38d0.png | |
filePath | string | 否 | 文件路径。格式为:bzfile://user/bosshi.png, 其中 bzfile://user/为固定格式,bosshi.png 为文件名。 如果不填则给一个随机路径。不支持网络地址 示例值:bzfile://user/bosshi.png |
# 输出
继承标准对象输出,success
返回对象的扩展属性:
名称 | 数据类型 | 描述 |
---|---|---|
savedFilePath | string | 保存后的文件路径 |
# 示例代码
bz.chooseImage({
success(res) {
const tempFilePath = res.tempFilePaths[0];
bz.saveFile({
tempFilePath,
filePath: "bzfile://user/feishu.png",
success(res) {
console.log(`${JSON.stringify(res)}`);
},
fail(res) {
console.log(`saveFile fail: ${JSON.stringify(res)}`);
},
});
},
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
success
返回对象示例:
{
"savedFilePath": "bzfile://user/bosshi.png",
"errMsg": "saveFile:ok"
}
1
2
3
4
2
3
4