Skip to content

保存为二进制文件 v1.11.0 ​

方法名 ​

saveToBinary

用法 ​

用法示例 ​

js
module.saveToBinary({
  //文件保存路径
  path: "/storage/emulated/0/leven_file/1.bin",
  //文件内容
  content: ""
}, res => {
  console.log(JSON.stringify(res))
})

参数说明 ​

参数名参数类型是否必填默认值参数描述
pathString是无文件路径
contentString是无文件内容

回调 ​

回调示例 ​

json
{
  "data": {
    "status": "onStart"
  },
  "message": "",
  "code": 0
}

回调说明 ​

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.statusString写入状态,onStart:开始写入,onProgress:写入进度,onComplete:写入完成,onFail:写入失败
data.pathString写入的文件路径
data.totalInteger写入的文件总大小,单位:字节
data.positionInteger当前写入的大小,单位:字节
data.progressFloat写入的进度,百分比需要*100
data.lengthInteger写入完成后文件大小,onComplete时返回
data.messageString错误信息,onFail时返回
codeInteger返回类型,0.成功,其他:失败