space.fs.mkdir()
Create an empty folder in a bucket, so it shows in lists before it holds any files.
Creates a folder in a bucket. Folders also appear on their own when you write a file into them, so create one only to show an empty folder in lists before it holds any files. Creating a folder that already exists resolves to it again.
space.fs.mkdir(
path: string | { bucket: string; key: string },
options?: {
signal?: AbortSignal
timeoutMs?: number
}
): Promise<Folder>Parameters
pathstring | { bucket, key }The folder to create:
bucket/folderas one string, such asinvoices/2026/q1, or an object such as{ bucket: "invoices", key: "2026/q1" }.- The bucket is 3 to 63 lowercase letters, digits, and single hyphens, starting and ending with a letter or digit.
- The folder follows the rules for keys: 1 to 1,024 bytes, and 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 folder, an Entry with type set to folder and a prefix that ends in /, such as 2026/q1/.
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 does not exist |
forbidden | The API key may not upload files |
Every call can also fail with the codes listed on SpaceError, such as timeout and network_error.
Example
import { space } from "digitospace"
const folder = await space.fs.mkdir("invoices/2026/q4")
console.log(`Created ${folder.prefix}`)Last updated