Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • StorageAPI

Index

Methods

fetchByCid

  • fetchByCid(cid: string): Promise<Response>
  • Parameters

    • cid: string

    Returns Promise<Response>

status

  • Retrieve the status of a storage request from a remote provider.

    Parameters

    • id: string

      The id of the storage request, as returned from the store function.

    Returns Promise<RequestStatus>

    Promise that resolves to a RequestStatus object.

statusByCid

  • Retrieve the status of a storage request from a remote provider.

    Parameters

    • id: string

    Returns Promise<RequestStatus[]>

    Promise that resolves to an array of storage RequestStatus objects.

store

  • Create a storage request with a remote provider.

    In a browser, data should be a File object. In NodeJS, specify a Readable stream of the FormData bytes. See the example for details.

    example
    Browser usage const blob = new Blob(["Hello, world!"], { type: "text/plain" }); const file = new File([blob], "welcome.txt", { type: "text/plain", lastModified: new Date().getTime() }); storage.store(file) .then((request) => console.log(request));
    example
    NodeJS usage import { FormData } from "formdata-node"; import { Encoder } from "form-data-encoder"; import { Readable } from "stream";

    const formData = new NodeForm(); formData.set("file", "Hello, world!"); const encoder = new Encoder(formData); const readable = Readable.from(encoder); storage.store(readable, { headers: encoder.headers }) .then((request) => console.log(request));

    Parameters

    • data: File | Readable

      The File or Readable stream object to upload.

    • Optional config: OpenOptions

    Returns Promise<StorageRequest>

    Promise that resolves to a storage Request object.

Generated using TypeDoc