Options
All
  • Public
  • Public/Protected
  • All
Menu

Storage Manager

Index

References

Renames and re-exports StorageManager

Variables

constants: typeof constants
path: PlatformPath

Functions

  • Delete(filePath: string, callback?: (err: null | ErrnoException) => any): Promise<void>
  • Wrapper of delete operation in filesystem.

    Parameters

    • filePath: string

      A path to unlink or delete from filesystem.

    • Optional callback: (err: null | ErrnoException) => any

      Optional callback called after delete operation is finished.

        • (err: null | ErrnoException): any
        • Parameters

          • err: null | ErrnoException

          Returns any

    Returns Promise<void>

    A promise of the delete operation.

  • append(path: string, value: Input, charset?: BufferEncoding): Promise<boolean>
  • Wrapper to append file with data.

    Parameters

    • path: string

      Path to write file.

    • value: Input

      Plain string to append to file, or Buffer instance, or serializable (as JSON) object.

    • charset: BufferEncoding = 'utf-8'

      Optional charset of data. Default is "utf-8".

    Returns Promise<boolean>

  • appendStreamed(path: string, values: AsyncIterable<Input>, charset?: BufferEncoding): Promise<void>
  • appendStreamed(path: string, values: Iterable<Input>, charset?: BufferEncoding): Promise<void>
  • appendStreamed(path: string, value: Input, charset?: BufferEncoding): Promise<void>
  • Wrapper to append file with data.

    Parameters

    • path: string

      Path to write file.

    • values: AsyncIterable<Input>

      You can provide an async iterable object to write on demand or a synchronous one to group inputs before write.

    • Optional charset: BufferEncoding

      Optional charset of data. Default is "utf-8".

    Returns Promise<void>

  • Parameters

    • path: string
    • values: Iterable<Input>
    • Optional charset: BufferEncoding

    Returns Promise<void>

  • Parameters

    • path: string
    • value: Input
    • Optional charset: BufferEncoding

    Returns Promise<void>

  • checkExist(path: string, cb?: (exists?: boolean | PromiseLike<boolean>) => any): Promise<boolean>
  • Wrapper to check if a path already exists in filesystem.

    deprecated

    @see StorageManager.exists()

    Parameters

    • path: string

      Path to check avaiability.

    • Optional cb: (exists?: boolean | PromiseLike<boolean>) => any

      Optional callback to run after async check.

        • (exists?: boolean | PromiseLike<boolean>): any
        • Parameters

          • Optional exists: boolean | PromiseLike<boolean>

          Returns any

    Returns Promise<boolean>

    A promise of existance check.

  • copy(from: string, to: string, as?: string): Promise<void>
  • Wrapper to copy a file or a directory to a given directory.

    since

    1.4.0

    Parameters

    • from: string

      Path to a file or directory.

    • to: string

      Path of new directory to copy (input will be put inside this path).

    • Optional as: string

      Optional new name of file or directory.

    Returns Promise<void>

  • deleteFromStorage(filePath: string, callback?: (err: null | ErrnoException) => any): Promise<void>
  • Wrapper of delete operation in filesystem.

    Parameters

    • filePath: string

      A path to unlink or delete from filesystem.

    • Optional callback: (err: null | ErrnoException) => any

      Optional callback called after delete operation is finished.

        • (err: null | ErrnoException): any
        • Parameters

          • err: null | ErrnoException

          Returns any

    Returns Promise<void>

    A promise of the delete operation.

  • doesntExist(path: string): Promise<boolean>
  • doesntExist(path: string, mode: number): Promise<boolean>
  • doesntExist(path1: string, path2: string): Promise<boolean>
  • doesntExist(path1: string, path2: string, mode: number): Promise<boolean>
  • doesntExist(path1: string, path2: string, path3: string): Promise<boolean>
  • doesntExist(path1: string, path2: string, path3: string, mode: number): Promise<boolean>
  • doesntExist(path1: string, path2: string, path3: string, path4: string): Promise<boolean>
  • doesntExist(path1: string, path2: string, path3: string, path4: string, mode: number): Promise<boolean>
  • doesntExist(...paths: string[]): Promise<boolean>
  • doesntExist(...args: (string | number)[]): Promise<boolean>
  • Wrapper to check if a path does not exist in filesystem. Is the oposite of exists() method.

    Parameters

    • path: string

      Path to check unavaiability.

    Returns Promise<boolean>

    A promise of non-existance check.

  • Wrapper to check if a path does not exist in filesystem. Is the oposite of exists() method.

    Parameters

    • path: string

      Path to check unavaiability.

    • mode: number

      Optional access mode flags to check unavaiability (see: {@link fs.constants NodeJS.fs.constants}).

    Returns Promise<boolean>

    A promise of non-existance check.

  • Parameters

    • path1: string
    • path2: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • mode: number

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • mode: number

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • path4: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • path4: string
    • mode: number

    Returns Promise<boolean>

  • Wrapper to check if a path does not exist in filesystem. Is the oposite of exists() method.

    Parameters

    • Rest ...paths: string[]

      Paths to check in a row.

    Returns Promise<boolean>

    A promise of non-existance check.

  • Parameters

    • Rest ...args: (string | number)[]

    Returns Promise<boolean>

  • exists(path: string): Promise<boolean>
  • exists(path: string, mode: number): Promise<boolean>
  • exists(path1: string, path2: string): Promise<boolean>
  • exists(path1: string, path2: string, mode: number): Promise<boolean>
  • exists(path1: string, path2: string, path3: string): Promise<boolean>
  • exists(path1: string, path2: string, path3: string, mode: number): Promise<boolean>
  • exists(path1: string, path2: string, path3: string, path4: string): Promise<boolean>
  • exists(path1: string, path2: string, path3: string, path4: string, mode: number): Promise<boolean>
  • exists(...paths: string[]): Promise<boolean>
  • exists(...args: (string | number)[]): Promise<boolean>
  • Wrapper to check if a path already exists in filesystem.

    Parameters

    • path: string

      Path to check avaiability.

    Returns Promise<boolean>

    A promise of existance check.

  • Wrapper to check if a path already exists in filesystem.

    Parameters

    • path: string

      Path to check avaiability.

    • mode: number

      Optional access mode flags to check avaiability (see: {@link fs.constants NodeJS.fs.constants}).

    Returns Promise<boolean>

    A promise of existance check.

  • Parameters

    • path1: string
    • path2: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • mode: number

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • mode: number

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • path4: string

    Returns Promise<boolean>

  • Parameters

    • path1: string
    • path2: string
    • path3: string
    • path4: string
    • mode: number

    Returns Promise<boolean>

  • Wrapper to check if a path already exists in filesystem.

    Parameters

    • Rest ...paths: string[]

      paths to check in a row

    Returns Promise<boolean>

    A promise of existance check.

  • Parameters

    • Rest ...args: (string | number)[]

    Returns Promise<boolean>

  • fileStream(path: string): Duplex
  • fileStream(path: string, mode: "r", options?: null | ReadableOptions, fsOptions?: null | NodeJS_fsReadOptions): Readable
  • fileStream(path: string, mode: "w", options?: null | WritableOptions, fsOptions?: null | NodeJS_fsWriteOptions): Writable
  • fileStream(path: string, mode: "rw", options?: null | DuplexOptions, fsOptions?: null | NodeJS_fsDuplexOptions): Duplex
  • Create a stream of file at given path.

    Parameters

    • path: string

      Path to file

    Returns Duplex

    Stream object of file

  • Parameters

    • path: string
    • mode: "r"
    • Optional options: null | ReadableOptions
    • Optional fsOptions: null | NodeJS_fsReadOptions

    Returns Readable

  • Parameters

    • path: string
    • mode: "w"
    • Optional options: null | WritableOptions
    • Optional fsOptions: null | NodeJS_fsWriteOptions

    Returns Writable

  • Parameters

    • path: string
    • mode: "rw"
    • Optional options: null | DuplexOptions
    • Optional fsOptions: null | NodeJS_fsDuplexOptions

    Returns Duplex

  • get(path: string, encoding?: BufferEncoding): Promise<string>
  • Wrapper to read file (load all data in string, intended for small files like config. files).

    Parameters

    • path: string

      Path to read file.

    • encoding: BufferEncoding = 'utf-8'

      Optional encoding of string. Default is "utf-8".

    Returns Promise<string>

    The string content of the file.

  • getAsBuffer(path: string): Promise<Buffer>
  • Wrapper to read file (load all data into a single buffer, intended for small binary files).

    Parameters

    • path: string

      Path to read file.

    Returns Promise<Buffer>

    The array with the binary buffers streamed of the file.

  • getAsBuffers(path: string): Promise<Buffer[]>
  • Wrapper to read file (load all data into array of buffers, intended for small binary files).

    Parameters

    • path: string

      Path to read file.

    Returns Promise<Buffer[]>

    The array with the binary buffers streamed of the file.

  • getAsJSON(path: string, encoding?: BufferEncoding, reviver?: (key: string, value: any) => any): Promise<unknown>
  • Wrapper to read file as JSON (load all data into a single buffer, intended for small binary files).

    since

    1.2.0

    Parameters

    • path: string

      Path to read JSON file (be careful to do not load huge JSONs, as it will load entire JSON file in string before parsing).

    • encoding: BufferEncoding = 'utf8'

      file encoding to parse, default is "utf-8".

    • Optional reviver: (key: string, value: any) => any

      A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.

        • (key: string, value: any): any
        • Parameters

          • key: string
          • value: any

          Returns any

    Returns Promise<unknown>

  • getFileContents(filePath: string, cb?: (err: undefined | null | Error, arrayBuffer?: Buffer[]) => void): Promise<Buffer[]>
  • Assynchronously reads given file at default storage. Supports Callback syntax and Promise syntax.

    deprecated

    @see StorageManager.getAsBuffers()

    Parameters

    • filePath: string

      path to the file in default storage.

    • Optional cb: (err: undefined | null | Error, arrayBuffer?: Buffer[]) => void

      optional callback to handle output and error. If not provided it resolve as a Promise

        • (err: undefined | null | Error, arrayBuffer?: Buffer[]): void
        • Parameters

          • err: undefined | null | Error
          • Optional arrayBuffer: Buffer[]

          Returns void

    Returns Promise<Buffer[]>

  • isDirectory(path: string): Promise<boolean>
  • Checks if given path corresponds to a directory

    Parameters

    • path: string

    Returns Promise<boolean>

  • isFile(path: string): Promise<boolean>
  • Checks if given path corresponds to a file

    Parameters

    • path: string

    Returns Promise<boolean>

  • listDirectory(path: string): Promise<string[]>
  • listDirectory(path: string, recursive: false): Promise<string[]>
  • listDirectory(path: string, recursive: true): Promise<DirectoryList>
  • mkdir(path: string, options?: MakeDirectoryOptions, cb?: (err: null | ErrnoException, path?: string) => null): Promise<null | ErrnoException>
  • Wrapper function to directory creation in filesystem (recursive or not).

    Parameters

    • path: string

      Path to search in filesystem.

    • options: MakeDirectoryOptions = ...

      Filesystem options for mkdir operation.

    • Optional cb: (err: null | ErrnoException, path?: string) => null

      Optional callback for mkdir async operation.

        • (err: null | ErrnoException, path?: string): null
        • Parameters

          • err: null | ErrnoException
          • Optional path: string

          Returns null

    Returns Promise<null | ErrnoException>

    A promise of mkdir operation.

  • move(from: string, to: string, as?: string): Promise<void>
  • Wrapper to move a file, or directory.

    since

    1.4.0

    Parameters

    • from: string

      Current path.

    • to: string

      New path.

    • Optional as: string

      Optional renaming.

    Returns Promise<void>

  • openFileOrDirectory(path: string, ifFile?: (err: null | ErrnoException, data: string) => void, ifDir?: (err: null | ErrnoException, files: string[]) => void, encoding?: BufferEncoding): Promise<void>
  • Wrapper for opening attempts to a path, be file or directory.

    deprecated

    @see StorageManager.stats()

    Parameters

    • path: string

      Path to open a file or list directory.

    • Optional ifFile: (err: null | ErrnoException, data: string) => void

      Optional callback called if path leads to a file.

        • (err: null | ErrnoException, data: string): void
        • Parameters

          • err: null | ErrnoException
          • data: string

          Returns void

    • Optional ifDir: (err: null | ErrnoException, files: string[]) => void

      Optional callback called if path leads to a directory.

        • (err: null | ErrnoException, files: string[]): void
        • Parameters

          • err: null | ErrnoException
          • files: string[]

          Returns void

    • encoding: BufferEncoding = 'utf-8'

      Optional encoding for files, default utf-8.

    Returns Promise<void>

  • put(path: string, value: Input, charset?: BufferEncoding): Promise<boolean>
  • Wrapper to write in a given filename.

    Parameters

    • path: string

      Path to write file.

    • value: Input

      Plain string to insert into file, or Buffer instance, or serializable (as JSON) object.

    • charset: BufferEncoding = 'utf-8'

      Optional charset of data. Default is "utf-8".

    Returns Promise<boolean>

  • putStreamed(path: string, values: AsyncIterable<Input>, charset?: BufferEncoding): Promise<void>
  • putStreamed(path: string, values: Iterable<Input>, charset?: BufferEncoding): Promise<void>
  • putStreamed(path: string, value: Input, charset?: BufferEncoding): Promise<void>
  • Wrapper to write in a given filename.

    Parameters

    • path: string

      Path to write file.

    • values: AsyncIterable<Input>

      You can provide an async iterable object to write on demand or a synchronous one to group inputs before write.

    • Optional charset: BufferEncoding

      Optional charset of data. Default is "utf-8".

    Returns Promise<void>

  • Parameters

    • path: string
    • values: Iterable<Input>
    • Optional charset: BufferEncoding

    Returns Promise<void>

  • Parameters

    • path: string
    • value: Input
    • Optional charset: BufferEncoding

    Returns Promise<void>

  • readFileStream(filePath: string, opts?: WritableOptions | Writable, cb?: (err?: null | Error) => void): Writable
  • Creates an Writable stream to transform/process chunk data from a file, piping'em, and returns the writed stream.

    deprecated

    @see StorageManager.readStream()

    Parameters

    • filePath: string

      path to the file in default storage.

    • Optional opts: WritableOptions | Writable

      options to setup the write stream.

    • Optional cb: (err?: null | Error) => void

      optional callback to error handling (default console.error output stream).

        • (err?: null | Error): void
        • Parameters

          • Optional err: null | Error

          Returns void

    Returns Writable

  • readStorage(filePath: string, out: Writable): Promise<void>
  • Reads given file asynchronously on-demand and pipe out to given writable stream

    deprecated

    Obsolete and unsafe code using Stream.pipe(stream: Stream.Writable). Prefer Stream.pipeline(...streams: Stream[, cb: err => void]) implementation at StorageManager.readFileStream(...)

    deprecated

    @see StorageManager.readStream()

    Parameters

    • filePath: string

      path to the file in default storage

    • out: Writable

      writable stream to output retrieved data

    Returns Promise<void>

  • readStream(path: string, options?: null | ReadableOptions, fsOptions?: null | NodeJS_fsReadOptions): Readable
  • Create a readable stream of file at given path.

    Parameters

    • path: string

      Path to file

    • Optional options: null | ReadableOptions

      Optional {@link Stream.ReadableOptions node:stream.ReadableOptions} object to customize stream

    • Optional fsOptions: null | NodeJS_fsReadOptions

      Optional settings for underlying fs stream.

    Returns Readable

    Readable stream object of file

  • rename(path: string, renameTo: string): Promise<void>
  • Wrapper to rename a file, or directory.

    since

    1.4.0

    Parameters

    • path: string

      Current path.

    • renameTo: string

      New name to file or directory.

    Returns Promise<void>

  • stats(path: string): Promise<Stats>
  • Wrapper to retrieve stats of a given path

    since

    1.4.0

    Parameters

    • path: string

      Path to retrieve stats.

    Returns Promise<Stats>

  • stream(path: string): Duplex
  • stream(path: string, mode: "r", options?: null | ReadableOptions, fsOptions?: null | NodeJS_fsReadOptions): Readable
  • stream(path: string, mode: "w", options?: null | WritableOptions, fsOptions?: null | NodeJS_fsWriteOptions): Writable
  • stream(path: string, mode: "rw", options?: null | DuplexOptions, fsOptions?: null | NodeJS_fsDuplexOptions): Duplex
  • Create a stream of file at given path.

    Parameters

    • path: string

      Path to file

    Returns Duplex

    Stream object of file

  • Parameters

    • path: string
    • mode: "r"
    • Optional options: null | ReadableOptions
    • Optional fsOptions: null | NodeJS_fsReadOptions

    Returns Readable

  • Parameters

    • path: string
    • mode: "w"
    • Optional options: null | WritableOptions
    • Optional fsOptions: null | NodeJS_fsWriteOptions

    Returns Writable

  • Parameters

    • path: string
    • mode: "rw"
    • Optional options: null | DuplexOptions
    • Optional fsOptions: null | NodeJS_fsDuplexOptions

    Returns Duplex

  • unlink(filePath: string, callback?: (err: null | ErrnoException) => any): Promise<void>
  • Wrapper of delete operation in filesystem.

    Parameters

    • filePath: string

      A path to unlink or delete from filesystem.

    • Optional callback: (err: null | ErrnoException) => any

      Optional callback called after delete operation is finished.

        • (err: null | ErrnoException): any
        • Parameters

          • err: null | ErrnoException

          Returns any

    Returns Promise<void>

    A promise of the delete operation.

  • writeFileStream(filePath: string, data: ArrayBuffer, chunkSize?: number, cb?: (err?: null | Error) => void): Promise<boolean>
  • Parameters

    • filePath: string

      File path to write in filesystem (if parent directory does not exist, create before write the file).

    • data: ArrayBuffer

      File data as ArrayBuffer.

    • chunkSize: number = 65536

      Chunk size of file.

    • Optional cb: (err?: null | Error) => void

      Optional callback called when write operation is finished.

        • (err?: null | Error): void
        • Parameters

          • Optional err: null | Error

          Returns void

    Returns Promise<boolean>

    A promise of the write operation.

  • writeStorage(filePath: string, f: Uint8Array | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): Promise<void>
  • writeStream(path: string, options?: null | WritableOptions, fsOptions?: null | NodeJS_fsWriteOptions): Writable
  • Create a writable stream of file at given path.

    Parameters

    • path: string

      Path to file

    • Optional options: null | WritableOptions

      Optional {@link Stream.WritableOptions node:stream.WritableOptions} object to customize stream

    • Optional fsOptions: null | NodeJS_fsWriteOptions

      Optional settings for underlying fs stream.

    Returns Writable

    Writable stream object of file

Generated using TypeDoc