Class Files

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, includeToken?: boolean): string
  • Returns the HTTP url for a file.

    Async

    Returns

    The file URL

    Parameters

    • id: string

      A file ID

    • Optional includeToken: boolean

    Returns string

  • readFile(id: string): Promise<Readable<Uint8Array, Uint8Array, Uint8Array, true, false, ReadableEvents<Uint8Array>>>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; log?: ((msg: string) => void); opening?: boolean; params?: Record<string, any>; requestType?: "buffer" | "stream" | "json"; responseType?: "buffer" | "stream" | "json" | "text" | "raw"; token?: string } & { responseType: undefined }): Promise<Readable<Uint8Array, Uint8Array, Uint8Array, true, false, ReadableEvents<Uint8Array>>>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; log?: ((msg: string) => void); opening?: boolean; params?: Record<string, any>; requestType?: "buffer" | "stream" | "json"; responseType?: "buffer" | "stream" | "json" | "text" | "raw"; token?: string } & { responseType: "text" }): Promise<string>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; log?: ((msg: string) => void); opening?: boolean; params?: Record<string, any>; requestType?: "buffer" | "stream" | "json"; responseType?: "buffer" | "stream" | "json" | "text" | "raw"; token?: string } & { responseType: "buffer" }): Promise<Uint8Array>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; log?: ((msg: string) => void); opening?: boolean; params?: Record<string, any>; requestType?: "buffer" | "stream" | "json"; responseType?: "buffer" | "stream" | "json" | "text" | "raw"; token?: string } & { responseType: "stream" }): Promise<ReadableStream<Uint8Array>>
  • readFile(id: string, opts?: RangeOpts & Omit<RequestInit, "body"> & { body?: any; endpoint?: string; headers?: Record<string, string>; log?: ((msg: string) => void); opening?: boolean; params?: Record<string, any>; requestType?: "buffer" | "stream" | "json"; responseType?: "buffer" | "stream" | "json" | "text" | "raw"; token?: string } & { responseType: "raw" }): Promise<Response>
  • 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

    Returns Promise<Readable<Uint8Array, Uint8Array, Uint8Array, true, false, ReadableEvents<Uint8Array>>>

  • Parameters

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

    Returns Promise<Readable<Uint8Array, Uint8Array, Uint8Array, true, false, ReadableEvents<Uint8Array>>>

  • Parameters

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

    Returns Promise<string>

  • Parameters

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

    Returns Promise<Uint8Array>

  • Parameters

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

    Returns Promise<ReadableStream<Uint8Array>>

  • Parameters

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

    Returns Promise<Response>

  • 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