Skip to main content
zerotal

Documentation


Documentation / zerotal / storage / LocalDriver

Class: LocalDriver

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:12

Local filesystem driver — backed by Bun.file / Bun.write. Suitable for single-server deployments and local development.

Implements

Constructors

Constructor

new LocalDriver(_root, _urlBase?): LocalDriver

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:15

Parameters

_root

string

_urlBase?

string | undefined

Returns

LocalDriver

Methods

put()

put(path, content, _options?): Promise<void>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:41

Parameters

path

string

content

string | Blob | Uint8Array<ArrayBufferLike>

_options?

PutOptions

Returns

Promise<void>

Implementation of

StorageDriver.put


append()

append(path, content): Promise<void>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:49

Append to the end of a file, creating it when absent.

Only a filesystem can do this. An object store rewrites the whole object on every write, so emulating an append there would quietly turn one line of a log into a full download-and-upload of the day's file — S3Driver throws UnsupportedOperationError rather than pretend. Use it for things that are genuinely local and line-oriented, like the log trail.

Parameters

path

string

content

string | Uint8Array<ArrayBufferLike>

Returns

Promise<void>

Implementation of

StorageDriver.append


get()

get(path): Promise<string | null>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:58

Parameters

path

string

Returns

Promise<string | null>

Implementation of

StorageDriver.get


stream()

stream(path): Promise<Blob | null>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:64

A lazy handle for path, or null when absent.

Optional. When a backend can hand back something streamable, serving a file does not have to read it into memory first — which is the difference between serving a 2 GB video and falling over. StorageFilesMiddleware uses it when present and falls back to getBuffer when not.

Parameters

path

string

Returns

Promise<Blob | null>

Implementation of

StorageDriver.stream


getBuffer()

getBuffer(path): Promise<Uint8Array<ArrayBufferLike> | null>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:71

Parameters

path

string

Returns

Promise<Uint8Array<ArrayBufferLike> | null>

Implementation of

StorageDriver.getBuffer


exists()

exists(path): Promise<boolean>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:77

Parameters

path

string

Returns

Promise<boolean>

Implementation of

StorageDriver.exists


delete()

delete(path): Promise<void>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:81

Parameters

path

string

Returns

Promise<void>

Implementation of

StorageDriver.delete


url()

url(path): string

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:85

Return a public URL for the given path.

Parameters

path

string

Returns

string

Implementation of

StorageDriver.url


copy()

copy(source, destination): Promise<void>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:90

Copy a file within the same disk.

Parameters

source

string

destination

string

Returns

Promise<void>

Implementation of

StorageDriver.copy


move()

move(source, destination): Promise<void>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:94

Move (rename) a file within the same disk.

Parameters

source

string

destination

string

Returns

Promise<void>

Implementation of

StorageDriver.move


size()

size(path): Promise<number | null>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:98

Return the file size in bytes, or null if not found.

Parameters

path

string

Returns

Promise<number | null>

Implementation of

StorageDriver.size


lastModified()

lastModified(path): Promise<number | null>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:104

Return the last-modified timestamp (ms since epoch), or null if not found.

Parameters

path

string

Returns

Promise<number | null>

Implementation of

StorageDriver.lastModified


temporaryUrl()

temporaryUrl(path, expiresInSeconds): Promise<string>

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:116

Local signed URL — encodes path + expiry in a HMAC-signed query string, keyed off APP_KEY (throws when it is unset, so a signed URL is never emitted with a guessable key). The signature is validated server-side by your application's route handler; verify it with verifyTemporaryUrl.

Parameters

path

string

expiresInSeconds

number

Returns

Promise<string>

Implementation of

StorageDriver.temporaryUrl


verifyTemporaryUrl()

static verifyTemporaryUrl(path, expiresAt, signature): boolean

Defined in: packages/core/src/storage/drivers/LocalDriver.ts:127

Verify a signature produced by temporaryUrl. Returns false when the link has expired or the signature does not match (constant-time).

Parameters

path

string

expiresAt

number

signature

string

Returns

boolean