space.fs.stat()

Get a file’s size, media type, digest, and times without downloading it.

Gets a file’s details, such as its size, media type, and when it last changed, without downloading its contents. To only ask whether a file is there, use space.fs.exists().

space.fs.stat(
  path: string | { bucket: string; key: string },
  options?: {
    signal?: AbortSignal
    timeoutMs?: number
  }
): Promise<StoredFile>

Parameters

pathstring | { bucket, key }Required

The file: bucket/key as one string, such as invoices/2026/0001.pdf, or an object such as { bucket: "invoices", key: "2026/0001.pdf" }.

  • The bucket is 3 to 63 lowercase letters, digits, and single hyphens, starting and ending with a letter or digit.
  • The key is 1 to 1,024 bytes. It cannot start or end with /, hold //, have a folder named . or .., or hold control characters.
options.signalAbortSignal

Cancels the call when it aborts. The promise then rejects with aborted.

options.timeoutMsnumber

The longest each request may take, in milliseconds. The client’s timeoutMs when you leave it out, 30,000 by default.

Returns

A promise for the File.

Errors

The promise rejects with a SpaceError. The call never throws before it returns the promise, and when an argument is wrong, nothing is sent.

CodeWhen
validation_failedThe path is wrong. issues names each field, such as path.key
not_foundThe bucket or the file does not exist. resource says which
forbiddenThe API key may not view files

Every call can also fail with the codes listed on SpaceError, such as timeout and network_error.

Example

check-invoice.ts
import { space } from "digitospace"

const file = await space.fs.stat("invoices/2026/0001.pdf")

console.log(`${file.key} is ${file.size} bytes of ${file.contentType}`)
console.log(`Last changed ${file.updatedAt}`)

Last updated