Describes the file on the device.

Constructors

  • Creates a new File instance.

    Parameters

    • eventBridge: EventBridge

      The underlying event bridge.

    • uri: string

      The URI that denotes the file.

    Returns File

Properties

uri: string

The URI that denotes the file.

Accessors

  • get contentUri(): string
  • The content URI of the file that can be shared with other applications.

    Returns string

  • get creationTime(): number
  • The time when the file was created.

    Returns number

  • get isDirectory(): boolean
  • true if the file is a directory.

    Returns boolean

  • get isExisting(): number
  • true is the file exists.

    Returns number

  • get isFile(): boolean
  • true if the file is a regular file with opaque content.

    Returns boolean

  • get isOther(): boolean
  • true if the file is something other than a regular file, directory, or symbolic link.

    Returns boolean

  • true if the file is a symbolic link.

    Returns boolean

  • get lastAccessTime(): number
  • The time of the last access.

    Returns number

  • get lastModifiedTime(): number
  • The time of the last modification.

    Returns number

  • get localUrl(): string
  • The URL that can be loaded by the web view.

    Returns string

  • get parentFile(): null | File
  • The file that represents the parent directory, or null if there's no parent directory.

    Returns null | File

  • get size(): number
  • The size of the file (in bytes).

    The size may differ from the actual size on the file system due to compression, support for sparse files, or other reasons. The size of files that are not regular files is implementation specific and therefore unspecified.

    Returns number

Methods

  • Appends binary data to the file.

    Parameters

    Returns Promise<void>

  • Appends text to the file.

    Parameters

    • text: string

      The text to append.

    • encoding: string = 'utf-8'

      The expected file encoding.

    Returns Promise<void>

  • Copies file contents to a new location.

    Parameters

    • to: File

      The location to which contents must be copied.

    Returns Promise<void>

  • Deletes the file.

    Returns Promise<boolean>

    true if the file was deleted, or false otherwise.

  • Creates a directory denoted by this file.

    Returns Promise<boolean>

    true if the directory was created, or false otherwise.

  • Reads the binary file contents as base64-encoded string.

    Returns Promise<string>

  • Reads text file contents as a string.

    Parameters

    • encoding: string = 'utf-8'

      The expected file encoding.

    Returns Promise<string>

  • Returns the uri of the file.

    Returns string

  • Writes the new binary content to a file.

    If file doesn't exist then it is created. If file exists, it is overwritten.

    Parameters

    Returns Promise<void>

  • Writes the new text content to a file.

    If file doesn't exist then it is created. If file exists, it is overwritten.

    Parameters

    • text: string

      The new text file contents.

    • encoding: string = 'utf-8'

      The expected file encoding.

    Returns Promise<void>