FileSystemManager.saveFile

Requires:
BaseKit≥2.4.3
Platforms:
iOSAndroid

Method signature
FileSystemManager.saveFile(params: )

Description

Save a copy of the file to the target path.

Parameters

PropertyTypeRequiredDescription
tempFilePathstringYesTemporary path of the file to store
filePathstringYesTarget path where the file will be stored
complete() => voidNoCompletion callback (executed on both success and failure)
success(params: Object) => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
success callback parameters
PropertyTypeDescriptionSince
savedFilePathstring[Deprecated, not recommended] Path of the stored filev3.2.6
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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

// saveFile saves a temporary file to the target path; write a source file to Temp first.
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);
  },
});