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?
Returns
Promise<void>
Implementation of
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
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
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
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
exists()
exists(
path):Promise<boolean>
Defined in: packages/core/src/storage/drivers/LocalDriver.ts:77
Parameters
path
string
Returns
Promise<boolean>
Implementation of
delete()
delete(
path):Promise<void>
Defined in: packages/core/src/storage/drivers/LocalDriver.ts:81
Parameters
path
string
Returns
Promise<void>
Implementation of
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
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
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
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
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
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
verifyTemporaryUrl()
staticverifyTemporaryUrl(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