Class JsFileContents

java.lang.Object
io.deephaven.web.client.api.storage.JsFileContents

@JsType(namespace="dh.storage", name="FileContents") public class JsFileContents extends Object
Represents a file's contents loaded from the server. If an etag was specified when loading, client should first test if the etag of this instance matches - if so, the contents will be empty, and the client's existing contents should be used.
  • Constructor Details

    • JsFileContents

      @JsIgnore public JsFileContents(elemental2.dom.Blob data, String etag)
    • JsFileContents

      @JsIgnore public JsFileContents(String etag)
  • Method Details

    • blob

      public static JsFileContents blob(elemental2.dom.Blob blob)
      Creates an instance from an existing Blob.
      Parameters:
      blob - The blob containing the file contents.
      Returns:
      A JsFileContents instance containing the provided data.
    • text

      public static JsFileContents text(String... text)
      Creates an instance from text.
      Parameters:
      text - One or more string parts to combine into a Blob.
      Returns:
      A JsFileContents instance containing the provided data.
    • arrayBuffers

      public static JsFileContents arrayBuffers(elemental2.core.ArrayBuffer... buffers)
      Creates an instance from one or more ArrayBuffer values.
      Parameters:
      buffers - One or more buffers to combine into a Blob.
      Returns:
      A JsFileContents instance containing the provided data.
    • text

      @JsMethod public elemental2.promise.Promise<String> text()
      Reads the contents as text.
      Returns:
      A promise that resolves to the file contents as a string.
    • arrayBuffer

      @JsMethod public elemental2.promise.Promise<elemental2.core.ArrayBuffer> arrayBuffer()
      Reads the contents as an ArrayBuffer.
      Returns:
      A promise that resolves to the file contents as an ArrayBuffer.
    • getEtag

      @JsProperty public String getEtag()
      The etag associated with the contents.

      If an etag was provided when loading and the server indicates that the client's cached contents are still valid, the contents of this instance may be empty and only the etag will be returned.