Remote service to read and write files on the server. Paths use "/" as a separator, and should not start with "/".

Hierarchy

  • StorageService

Constructors

Methods

  • Creates a new directory at the specified path.

    Parameters

    • path: string

      the path of the directory to create

    Returns Promise<void>

    a promise with no value on success, or an error.

  • Deletes the item at the given path. Directories must be empty to be deleted.

    Parameters

    • path: string

      the path of the item to delete

    Returns Promise<void>

    a promise with no value on success, or an error.

  • Lists items in a given directory, with an optional filter glob to only list files that match. The empty or "root" path should be specified as the empty string.

    Parameters

    • path: string

      the path of the directory to list

    • Optional glob: string

      optional glob to filter the contents of the directory

    Returns Promise<ItemDetails[]>

    a promise containing the any items that are present in the given directory that match the glob, or an error.

  • Downloads a file at the given path, unless an etag is provided that matches the file's current contents.

    Parameters

    • path: string

      the path of the file to fetch

    • Optional etag: string

      an optional etag from the last time the client saw this file

    Returns Promise<FileContents>

    a promise containing details about the file's contents, or an error.

  • Moves (and/or renames) an item from its old path to its new path. The optional newFile parameter can be passed to enforce that an existing item must not be overwritten.

    Note that directories must be empty to be overwritten.

    Parameters

    • oldPath: string

      the path of the existing item

    • newPath: string

      the new path to move the item to

    • Optional allowOverwrite: boolean

      true to allow an existing file to be overwritten, false or skip to require a new file

    Returns Promise<void>

    a promise with no value on success, or an error.

  • Saves the provided contents to the given path, creating a file or replacing an existing one. The optional newFile parameter can be passed to indicate that an existing file must not be overwritten, only a new file created.

    Note that directories must be empty to be overwritten.

    Parameters

    • path: string

      the path of the file to write

    • contents: FileContents

      the contents to write to that path

    • Optional allowOverwrite: boolean

      true to allow an existing file to be overwritten, false or skip to require a new file

    Returns Promise<FileContents>

    a promise with a FileContents, holding only the new etag (if the server emitted one), or an error