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 }The file:
bucket/keyas one string, such asinvoices/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.signalAbortSignalCancels the call when it aborts. The promise then rejects with
aborted.options.timeoutMsnumberThe longest each request may take, in milliseconds. The client’s
timeoutMswhen 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.
| Code | When |
|---|---|
validation_failed | The path is wrong. issues names each field, such as path.key |
not_found | The bucket or the file does not exist. resource says which |
forbidden | The API key may not view files |
Every call can also fail with the codes listed on SpaceError, such as timeout and network_error.
Example
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