File system for a collection.

Hierarchy

  • Files

Constructors

  • File system for a collection.

    Parameters

    Returns Files

Properties

collection: Collection

Methods

  • createFile(stream: any, metadata?: any, opts??: UploadFileOpts): Promise<any>
  • Create a new file

    Returns

    • The created file record

    Parameters

    • stream: any

      File content as stream or buffer

    • Optional metadata: any

      File record metadata (see file record schema)

    • Optional opts: UploadFileOpts = {}

      Options.

      • onUploadProgress: Callback to invoke with upload progress information

    Returns Promise<any>

  • getFileMetadata(id: string, opts?: FetchOpts): Promise<any>
  • Get the metadata for a file

    Async

    Throws

    Will throw if the path is not found.

    Returns

    The file record value (metadata)

    Parameters

    Returns Promise<any>

  • getURL(id: string): string
  • Returns the HTTP url for a file.

    Async

    Returns

    The file URL

    Parameters

    • id: string

      A file ID

    Returns string

  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "text" }): Promise<string>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "buffer" }): Promise<ArrayBuffer | Buffer>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "stream" }): Promise<ReadableStream<Uint8Array>>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "raw" }): Promise<Response>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any }): Promise<any>
  • Read a file into a buffer.

    Async

    Throws

    Will throw if the path is not found.

    Returns

    The file content. A Buffer object in Node.js, a ArrayBuffer object in the browser.

    Parameters

    • id: string

      A file ID

    • Optional opts: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "text" }

      Options. TODO: document.

    Returns Promise<string>

  • Parameters

    • id: string
    • Optional opts: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "buffer" }

    Returns Promise<ArrayBuffer | Buffer>

  • Parameters

    • id: string
    • Optional opts: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "stream" }

    Returns Promise<ReadableStream<Uint8Array>>

  • Parameters

    • id: string
    • Optional opts: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any } & { responseType: "raw" }

    Returns Promise<Response>

  • Parameters

    • id: string
    • Optional opts: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; opening?: boolean; params?: Record<string, any>; requestType?: "json" | "buffer" | "stream"; responseType?: "json" | "text" | "buffer" | "stream" | "raw"; token?: string; log?: any }

    Returns Promise<any>

  • updateFile(id: string, stream: any, metadata?: any, opts??: UploadFileOpts): Promise<any>
  • Update a file

    Returns

    • The created file record

    Parameters

    • id: string

      The file record id

    • stream: any

      File content as stream or buffer

    • Optional metadata: any

      File record metadata (see file record schema)

    • Optional opts: UploadFileOpts = {}

      Options.

      • onUploadProgress: Callback to invoke with upload progress information

    Returns Promise<any>

Generated using TypeDoc