# FileSystemManager.appendFile
在文件结尾追加内容。
# 支持说明
应用能力 | Android | iOS | PC | 预览效果 |
---|---|---|---|---|
小程序 | 3.12.0 | 3.11.0 | 3.10.0 | 扫码预览 用BoosHi扫码或PC端点击 |
网页应用 | 待开发 | 待开发 | 待开发 | 待补充 |
# 输入
继承标准对象输入,扩展属性描述:
名称 | 数据类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
filePath | string | 是 | 本地文件路径 | |
data | string/ArrayBuffer | 是 | 要写入的文本或二进制数据 | |
encoding | string | 否 | utf8 | 指定写入文件的字符编码,默认值仅在data为string类型时生效 |
# encoding 的合法值
值 | 说明 | Android | iOS | PC |
---|---|---|---|---|
ascii | 支持 | 支持 | 不支持 | |
base64 | 支持 | 支持 | 不支持 | |
binary | 支持 | 支持 | 不支持 | |
hex | 支持 | 支持 | 不支持 | |
ucs2/ucs-2/utf16le/utf-16le | 以小端序读取 | 支持 | 支持 | 不支持 |
utf-8/utf8 | 支持 | 支持 | 支持 | |
latin1 | 支持 | 支持 | 不支持 |
# 输出
继承标准对象输出,无扩展属性
# 代码示例
const fileSystemManager = bz.getFileSystemManager();
const filePath = `bzfile://user/example.txt`;
fileSystemManager.appendFile({
filePath,
encoding: "utf8",
data: "example append content",
success(_res) {
console.log("调用成功");
},
fail(res) {
console.log("调用失败", res.errMsg);
},
});
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