Class JsStorageService
java.lang.Object
io.deephaven.web.client.api.storage.JsStorageService
Remote service to read and write files on the server. Paths use "/" as a separator, and should not start with "/".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelemental2.promise.Promise<Void>
createDirectory
(String path) Creates a new directory at the specified path.elemental2.promise.Promise<Void>
deleteItem
(String path) Deletes the item at the given path.elemental2.promise.Promise<elemental2.core.JsArray<JsItemDetails>>
Lists items in a given directory, with an optional filter glob to only list files that match.elemental2.promise.Promise<JsFileContents>
Downloads a file at the given path, unless an etag is provided that matches the file's current contents.elemental2.promise.Promise<Void>
Moves (and/or renames) an item from its old path to its new path.elemental2.promise.Promise<JsFileContents>
saveFile
(String path, JsFileContents contents, Boolean allowOverwrite) Saves the provided contents to the given path, creating a file or replacing an existing one.
-
Constructor Details
-
JsStorageService
-
-
Method Details
-
listItems
@JsMethod public elemental2.promise.Promise<elemental2.core.JsArray<JsItemDetails>> listItems(String path, @JsOptional String glob) 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
- the path of the directory to listglob
- optional glob to filter the contents of the directory- Returns:
- a promise containing the any items that are present in the given directory that match the glob, or an error.
-
loadFile
@JsMethod public elemental2.promise.Promise<JsFileContents> loadFile(String path, @JsOptional String etag) Downloads a file at the given path, unless an etag is provided that matches the file's current contents.- Parameters:
path
- the path of the file to fetchetag
- an optional etag from the last time the client saw this file- Returns:
- a promise containing details about the file's contents, or an error.
-
deleteItem
Deletes the item at the given path. Directories must be empty to be deleted.- Parameters:
path
- the path of the item to delete- Returns:
- a promise with no value on success, or an error.
-
saveFile
@JsMethod public elemental2.promise.Promise<JsFileContents> saveFile(String path, JsFileContents contents, @JsOptional Boolean allowOverwrite) 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
- the path of the file to writecontents
- the contents to write to that pathallowOverwrite
- true to allow an existing file to be overwritten, false or skip to require a new file- Returns:
- a promise with a FileContents, holding only the new etag (if the server emitted one), or an error
-
moveItem
@JsMethod public elemental2.promise.Promise<Void> moveItem(String oldPath, String newPath, @JsOptional Boolean allowOverwrite) 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
- the path of the existing itemnewPath
- the new path to move the item toallowOverwrite
- true to allow an existing file to be overwritten, false or skip to require a new file- Returns:
- a promise with no value on success, or an error.
-
createDirectory
Creates a new directory at the specified path.- Parameters:
path
- the path of the directory to create- Returns:
- a promise with no value on success, or an error.
-