FileSystemManager.writeFile

Requires:
BaseKit≥2.4.3
Platforms:
iOSAndroid

Method signature
FileSystemManager.writeFile(params: )

Description

Write to a file; requires file read/write permission

Parameters

PropertyTypeRequiredDefaultDescription
filePathstringYes-The file path to write (local path)
datastringYes-Text data to write, encoded according to encoding
encodingstringNo"utf8"Specify the character encoding for writing the file; currently supports utf8/ascii/base64; defaults to utf8
complete() => voidNo-Completion callback (executed on both success and failure)
success() => voidNo-Callback on successful API call
fail(params: Object) => voidNo-Failure callback
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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

// File operation methods are exposed on the getFileSystemManager handle (fileId is injected automatically by the handle).
const fm = await getFileSystemManager();

fm.writeFile({
  filePath: "thingfile://usr/ttt_demo.txt",
  data: "hello ttt",
  encoding: "utf8",
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});