Reference

FilewayClient

API reference for the FilewayClient engine and its configuration

Constructor

new FilewayClient<TConfig extends FilewayConfig>(config: TConfig)

config

OptionTypeDescription
driverBaseDriverThe storage driver. See Drivers.
middlewaresMiddlewareHook[]Optional. Middleware run around uploads. See Middleware.
loggerLoggerOptional. Structured logger; receives info per operation and error on failure. See Observability.
onError(error, context) => void | Promise<void>Optional. Called (and awaited) before an error is re-thrown. Aborts are skipped. See Observability.

upload(stream, options)

Uploads a WHATWG ReadableStream<Uint8Array>.

ParamTypeDescription
streamReadableStream<Uint8Array>The file bytes. Never buffered whole by Local/S3.
optionsUploadOptionsSee the options table below.

Returns Promise<UploadResult<TMeta>> where TMeta is the driver's metadata type.

UploadOptions:

OptionTypeRequiredDescription
filenamestringOriginal file name.
pathstringFolder/path prefix for the stored object.
mimeTypestringContent type.
metadataRecord<string, string>Provider user metadata (see Metadata).
sizenumberKnown byte length — unlocks zero-buffer streaming (see Uploads).
signalAbortSignalCancels the upload in flight (see Uploads).
onProgress(progress) => voidProgress callback (see Uploads).

get(path)

Streams a stored file back as ReadableStream<Uint8Array> (see Downloads).

ParamTypeDescription
pathstringPath of the stored file.

Throws StorageError("not-found") when the file does not exist.

delete(path)

Deletes a stored file.

ParamTypeDescription
pathstringPath of the stored file.

Returns Promise<boolean>true when deleted, false when it was already gone.

getUrl(path)

Returns the public URL for a stored file (see Downloads).

ParamTypeDescription
pathstringPath of the stored file.

getPresignedUrl(path, options?)

Returns a time-limited, signed download URL. Only available on drivers that implement it (S3Driver, CloudinaryDriver); otherwise throws StorageError("config") (see Downloads).

ParamTypeDescription
pathstringPath of the stored file.
options.expiresInnumberLifetime in seconds (default 3600; bounds are driver-specific).

On this page