FileSystemManager.saveFile

版本要求:
BaseKit≥2.4.3
支持平台:
iOSAndroid

方法签名
FileSystemManager.saveFile(params: )

描述

将文件另存一份到目标路径中。

参数

属性类型必填说明
tempFilePathstring是需要存储的文件的临时路径
filePathstring是要存储的文件的目标路径
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)
success(params: Object) => void否接口调用成功的回调函数
fail(params: Object) => void否接口调用失败的回调函数
success 回调参数
属性类型说明最低版本
savedFilePathstring【待废弃, 不建议使用】存储后的文件路径v3.2.6
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { getFileSystemManager } from '@ray-js/ray'

// saveFile 把一个临时文件另存到目标路径;先在 Temp 写一个源文件。
const fm = await getFileSystemManager();

fm.writeFile({
  filePath: "thingfile://tmp/ttt_src.txt",
  data: "hello ttt",
  success: () => {
    fm.saveFile({
      tempFilePath: "thingfile://tmp/ttt_src.txt",
      filePath: "thingfile://usr/ttt_saved.txt",
      success: data => {
        console.log(data);
      },
      fail: error => {
        console.error(error);
      },
    });
  },
  fail: error => {
    console.error(error);
  },
});