Skip to main content

KIFS file access: uploads, downloads, and chunked uploads of large files.

Also reachable as GPUdb.FileHandler, matching the JavaScript API.

chunkSize: number = …

Size above which upload sends a file as a chunked multipart upload instead of in one request.

Matches the JavaScript API’s FileHandler.chunkSize, including its 60 MB default and its writability — callers that set their own threshold, as Cloud Workbench does, keep working unchanged.

gpuDB: GPUdb

The client used to reach the server

  • Downloads files from KIFS and returns their base64-encoded contents.

    Parameters

    • filenames: string | string[]

      KIFS path, or an array of paths

    • Optionaloptions: Record<string, string>

      Options for /download/files

    • Optionalcallback: GPUdbCallback

      Optional callback function

    Returns Promise<string[]>

    Promise resolving to the base64 contents, in request order

  • Downloads files from KIFS and writes them to a local directory.

    Node.js only — a browser cannot write to the filesystem. The directory is created if it does not exist.

    Parameters

    • filenames: string | string[]

      KIFS path, or an array of paths

    • destination: string

      Local directory to write into

    • Optionaloptions: Record<string, string>

      Options for /download/files

    • Optionalcallback: GPUdbCallback

      Optional callback function

    Returns Promise<string[]>

    Promise resolving to the paths written

  • Normalises a KIFS directory so it starts and ends with a slash.

    Parameters

    • Optionaldestination: string | null

      Directory path, possibly missing its slashes

    Returns string

  • Coerces a flag to the string form the server expects.

    Parameters

    • value: string | boolean | null | undefined

      Boolean or string flag

    • default_value: string

      Returned when the value is absent or unusable

    Returns string

  • Builds the options for a KIFS call, forcing the encoding this handler transfers in. Caller options are preserved, unlike the JavaScript API, which discards them.

    Parameters

    • incoming_options: Record<string, string> | null | undefined

      Options supplied by the caller

    • endpoint: string

      ’upload’ or ‘download’

    Returns Record<string, string>

  • Uploads files to KIFS.

    Accepts local paths (Node.js only) or Blob/File objects (any environment), singly or as an array. Unlike the JavaScript API, file contents are read as binary rather than UTF-8, so images, archives and other non-text files survive the round trip.

    Anything larger than chunkSize is sent through upload_multipart rather than in a single request, so a big file does not have to be held in one payload — the same threshold the JavaScript API applied. Everything smaller goes in one batched call.

    progress_callback reports the chunked portion of the work only, as a percentage from 0 to 100. When several files need chunking the percentage spans the whole set rather than restarting per file, so it rises monotonically to 100.

    Parameters

    • files: string | Blob | (string | Blob)[]

      Local paths, or Blob/File objects

    • Optionaldestination: string

      KIFS directory; defaults to the root

    • Optionaloptions: Record<string, string>

      Options for /upload/files

    • Optionalprogress_callback: UploadProgressCallback

      Percent complete; chunked uploads only

    • Optionalcallback: GPUdbCallback

      Optional callback function

    Returns Promise<boolean>

    Promise resolving to true when every file was accepted

  • Uploads one large file to KIFS in chunks.

    Initiates a multipart upload, sends each chunk in order, then completes it. If any chunk fails the upload is cancelled server-side before the error is rethrown, so no partial upload is left behind.

    Parameters

    • file: string | Blob

      Blob/File to upload, or a local path under Node.js

    • Optionaldestination: string

      KIFS directory; defaults to the root

    • chunk_size: number = …

      Bytes per chunk; defaults to 8 MB

    • Optionaloptions: Record<string, string>

      Options for /upload/files

    • Optionalprogress_callback: UploadProgressCallback

      Called with percent complete after each chunk

    • Optionalcallback: GPUdbCallback

      Optional callback function

    Returns Promise<string>

    Promise resolving to the multipart upload’s UUID

  • Returns the last segment of a path.

    Parameters

    • full_path: string

      Path to take the name from

    • sep: string = ’/‘

      Separator to split on

    Returns string