Skip to main content
zerotal

Documentation


Documentation / zerotal / storage / StorageDriver

Interface: StorageDriver

Defined in: packages/core/src/storage/types.ts:6

Methods

put()

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

Defined in: packages/core/src/storage/types.ts:7

Parameters

path

string

content

string | Blob | Uint8Array<ArrayBufferLike>

options?

PutOptions

Returns

Promise<void>


get()

get(path): Promise<string | null>

Defined in: packages/core/src/storage/types.ts:8

Parameters

path

string

Returns

Promise<string | null>


getBuffer()

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

Defined in: packages/core/src/storage/types.ts:9

Parameters

path

string

Returns

Promise<Uint8Array<ArrayBufferLike> | null>


exists()

exists(path): Promise<boolean>

Defined in: packages/core/src/storage/types.ts:10

Parameters

path

string

Returns

Promise<boolean>


delete()

delete(path): Promise<void>

Defined in: packages/core/src/storage/types.ts:11

Parameters

path

string

Returns

Promise<void>


url()

url(path): string

Defined in: packages/core/src/storage/types.ts:13

Return a public URL for the given path.

Parameters

path

string

Returns

string


copy()

copy(source, destination): Promise<void>

Defined in: packages/core/src/storage/types.ts:16

Copy a file within the same disk.

Parameters

source

string

destination

string

Returns

Promise<void>


move()

move(source, destination): Promise<void>

Defined in: packages/core/src/storage/types.ts:18

Move (rename) a file within the same disk.

Parameters

source

string

destination

string

Returns

Promise<void>


size()

size(path): Promise<number | null>

Defined in: packages/core/src/storage/types.ts:20

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

Parameters

path

string

Returns

Promise<number | null>


lastModified()

lastModified(path): Promise<number | null>

Defined in: packages/core/src/storage/types.ts:22

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

Parameters

path

string

Returns

Promise<number | null>


temporaryUrl()

temporaryUrl(path, expiresInSeconds): Promise<string>

Defined in: packages/core/src/storage/types.ts:27

Return a temporary URL valid for expiresInSeconds seconds. For local driver this is a signed token URL; for S3 it is a presigned URL.

Parameters

path

string

expiresInSeconds

number

Returns

Promise<string>


append()

append(path, content): Promise<void>

Defined in: packages/core/src/storage/types.ts:37

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>


stream()?

optional stream(path): Promise<Blob | null>

Defined in: packages/core/src/storage/types.ts:46

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>