Skip to main content

QStorageEngineBase

@quik/storage


@quik/storage / QStorageEngineBase

Abstract Class: QStorageEngineBase

Defined in: storage/src/engine/QStorageEngineBase.ts:11

Extends

  • QObject

Extended by

Constructors

Constructor

protected new QStorageEngineBase(name, type?): QStorageEngineBase

Defined in: storage/src/engine/QStorageEngineBase.ts:12

Parameters

name

string

type?

QStorageEngineType

Returns

QStorageEngineBase

Overrides

QObject.constructor

Properties

_name

protected _name: string

Defined in: storage/src/engine/QStorageEngineBase.ts:22

Storage engine name.


_type

protected _type: QStorageEngineType = QStorageEngineType.LOCAL

Defined in: storage/src/engine/QStorageEngineBase.ts:34

Storage engine type.

Accessors

logger

Get Signature

get protected logger(): IQLogger

Defined in: core/src/QObject.ts:15

The logger getter for the object.

Returns

IQLogger

Inherited from

QObject.logger


name

Get Signature

get name(): string

Defined in: storage/src/engine/QStorageEngineBase.ts:27

Storage engine name.

Returns

string

Overrides

QObject.name


type

Get Signature

get type(): QStorageEngineType

Defined in: storage/src/engine/QStorageEngineBase.ts:39

Storage engine type.

Returns

QStorageEngineType

Methods

copy()

abstract copy(sourcePath, destinationPath): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:168

Copy a file inside the same storage engine.

Parameters

sourcePath

string

Source storage path.

destinationPath

string

Destination storage path.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the source file is missing.


copyTo()

abstract copyTo(file, targetEngine, targetPath): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:178

Copy a file to another storage engine.

Parameters

file

QStorageFile

Source storage file.

targetEngine

QStorageEngineBase

Target storage engine.

targetPath

string

Destination path in the target engine.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the source file is missing.


create()

create(file, path, fill?): Promise<QStorageFile>

Defined in: storage/src/engine/QStorageEngineBase.ts:86

Save a file and return a refreshed metadata record.

Parameters

file

QStorageFile

Storage file to save.

path

string

Storage path where the file should be stored.

fill?

boolean = false

Whether to load contents into memory.

Returns

Promise<QStorageFile>


endSpan()

protected endSpan(span): void

Defined in: core/src/QObject.ts:35

End a span returned by startSpan.

Parameters

span

TelemetrySpan

The span to end.

Returns

void

Inherited from

QObject.endSpan


get()

abstract get(path, fill?): Promise<QStorageFile>

Defined in: storage/src/engine/QStorageEngineBase.ts:49

Fetch a file metadata record by path, optionally loading contents.

Parameters

path

string

Storage path for the file.

fill?

boolean

Whether to load contents into memory.

Returns

Promise<QStorageFile>


getSignedDownloadURL()

abstract getSignedDownloadURL(filePath, expiresIn?): Promise<string>

Defined in: storage/src/engine/QStorageEngineBase.ts:237

Build a signed, time-limited URL for downloading the file at the given path.

Parameters

filePath

string

Storage path to download.

expiresIn?

number

Expiration time in seconds. Falls back to the engine's configured default.

Returns

Promise<string>


getSignedUploadURL()

abstract getSignedUploadURL(filePath, expiresIn?): Promise<string>

Defined in: storage/src/engine/QStorageEngineBase.ts:229

Build a signed, time-limited URL for uploading content to the given path.

Parameters

filePath

string

Storage path the upload should be written to.

expiresIn?

number

Expiration time in seconds. Falls back to the engine's configured default.

Returns

Promise<string>


getUrl()

abstract getUrl(file, expiresIn?): Promise<string>

Defined in: storage/src/engine/QStorageEngineBase.ts:221

Resolve a public URL for the given file.

Parameters

file

QStorageFile

Storage file to resolve a URL for.

expiresIn?

number

Expiration time in seconds for signed URLs.

Returns

Promise<string>


importFromPath()

abstract importFromPath(sourcePath, destinationPath, removeSource?): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:213

Import a file from a filesystem path into this storage engine.

Parameters

sourcePath

string

OS path to the source file.

destinationPath

string

Storage path to save the file to.

removeSource?

boolean

Whether to delete the source file after upload.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the source file is missing.


init()

protected init(): void

Defined in: storage/src/engine/QStorageEngineBase.ts:239

Returns

void


move()

abstract move(sourcePath, destinationPath): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:159

Move a file inside the same storage engine.

Parameters

sourcePath

string

Source storage path.

destinationPath

string

Destination storage path.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the source file is missing.


moveTo()

abstract moveTo(file, targetEngine, targetPath): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:188

Move a file to another storage engine.

Parameters

file

QStorageFile

Source storage file.

targetEngine

QStorageEngineBase

Target storage engine.

targetPath

string

Destination path in the target engine.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the source file is missing.


new()

new(path, contents, options?): Promise<QStorageFile>

Defined in: storage/src/engine/QStorageEngineBase.ts:109

Create a new file from raw contents and return refreshed metadata.

Parameters

path

string

Storage path where the file should be stored.

contents

string | Buffer<ArrayBufferLike>

File contents (Buffer or string).

options?

Additional options.

encoding?

BufferEncoding

Text encoding when contents is a string and not base64. Defaults to utf-8 when isBase64 is false, otherwise binary.

fill?

boolean

Whether to return the entity with contents loaded.

isBase64?

boolean

When true, contents is already base64 encoded. Defaults to true for strings.

mimeType?

string

Override detected mime type.

Returns

Promise<QStorageFile>


read()

abstract read(file): Promise<QStorageFile>

Defined in: storage/src/engine/QStorageEngineBase.ts:143

Read a file into memory as base64 contents.

Parameters

file

QStorageFile

Storage file to read from.

Returns

Promise<QStorageFile>


readStream()

abstract readStream(path): Promise<ReadableStream>

Defined in: storage/src/engine/QStorageEngineBase.ts:150

Read a file as a stream without loading it into memory.

Parameters

path

string

Storage path to read.

Returns

Promise<ReadableStream>


recordSpanError()

protected recordSpanError(span, err): void

Defined in: core/src/QObject.ts:45

Record an exception on an active span.

Parameters

span

TelemetrySpan

The span to record the error on.

err

unknown

The error to record.

Returns

void

Inherited from

QObject.recordSpanError


remove()

abstract remove(path): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:196

Remove a file from storage.

Parameters

path

string

Storage path to remove.

Returns

Promise<void>

Throws

StorageFileNotFoundError when the target file is missing.


removeFolder()

abstract removeFolder(path): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:203

Remove a folder and its contents.

Parameters

path

string

Storage folder path to remove.

Returns

Promise<void>


save()

abstract save(file, path): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:57

Save a storage file at the given path.

Parameters

file

QStorageFile

Storage file to save.

path

string

Storage path where the file should be stored.

Returns

Promise<void>


saveStream()

abstract saveStream(path, stream, options?): Promise<void>

Defined in: storage/src/engine/QStorageEngineBase.ts:69

Save a stream to the given storage path.

Parameters

path

string

Storage path where the file should be stored.

stream

ReadableStream

Readable stream providing file contents.

options?

Additional options for the stream upload.

encoding?

BufferEncoding

Encoding for metadata when relevant.

mimeType?

string

Override detected mime type.

size?

number

Optional size hint in bytes.

Returns

Promise<void>


setSpanAttribute()

protected setSpanAttribute(span, key, value): void

Defined in: core/src/QObject.ts:64

Set a single attribute on an active span.

Parameters

span

TelemetrySpan

The span to update.

key

string

Attribute key.

value

string | number | boolean

Attribute value.

Returns

void

Inherited from

QObject.setSpanAttribute


startSpan()

protected startSpan(spanName, options?): TelemetrySpan

Defined in: core/src/QObject.ts:26

Start a telemetry span for the given operation name. Returns undefined when no telemetry provider is active.

Parameters

spanName

string

Name of the span.

options?

TelemetrySpanOptions

Optional span attributes and kind.

Returns

TelemetrySpan

Inherited from

QObject.startSpan