Skip to content

basalt / storage-gcs/src / GcsStorageDriver

Class: GcsStorageDriver ​

Defined in: storage-gcs/src/index.ts:103

Google Cloud Storage driver for @basaltkit/storage. Uses @google-cloud/storage (an optional peer dependency) via an injectable bucket, so its logic is unit-tested without touching GCS.

Implements ​

Constructors ​

Constructor ​

> new GcsStorageDriver(options): GcsStorageDriver

Defined in: storage-gcs/src/index.ts:107

Parameters ​

options ​

GcsDriverOptions

Returns ​

GcsStorageDriver

Properties ​

name ​

> readonly name: "gcs" = 'gcs'

Defined in: storage-gcs/src/index.ts:104

Human-readable driver name — used in error messages.

Implementation of ​

StorageDriver.name

Methods ​

copy() ​

> copy(from, to, options?): Promise<void>

Defined in: storage-gcs/src/index.ts:155

file.copy() — GCS rewrites the object server-side; the bytes never reach this process.

Parameters ​

from ​

string

to ​

string

options? ​

CopyDriverOptions

Returns ​

Promise<void>

Implementation of ​

StorageDriver.copy


delete() ​

> delete(path): Promise<boolean>

Defined in: storage-gcs/src/index.ts:197

Parameters ​

path ​

string

Returns ​

Promise<boolean>

Implementation of ​

StorageDriver.delete


disconnect() ​

> disconnect(): Promise<void>

Defined in: storage-gcs/src/index.ts:259

Returns ​

Promise<void>

Implementation of ​

StorageDriver.disconnect


exists() ​

> exists(path): Promise<boolean>

Defined in: storage-gcs/src/index.ts:192

Parameters ​

path ​

string

Returns ​

Promise<boolean>

Implementation of ​

StorageDriver.exists


get() ​

> get(path): Promise<Buffer<ArrayBufferLike>>

Defined in: storage-gcs/src/index.ts:128

Throws StorageFileNotFoundError when the file does not exist.

Parameters ​

path ​

string

Returns ​

Promise<Buffer<ArrayBufferLike>>

Implementation of ​

StorageDriver.get


getStream() ​

> getStream(path): Promise<Readable>

Defined in: storage-gcs/src/index.ts:146

createReadStream — the object's body as a Node readable. The caller must consume or destroy it.

Unlike the other drivers, GCS only discovers a missing object once the download starts, so StorageFileNotFoundError arrives as an error on the returned stream rather than as a rejected promise.

Parameters ​

path ​

string

Returns ​

Promise<Readable>

Implementation of ​

StorageDriver.getStream


list() ​

> list(prefix): Promise<string[]>

Defined in: storage-gcs/src/index.ts:203

Lists full object keys starting with prefix (the Disk layer passes the tenant scope in it). A plain string-prefix match is fine: the Disk narrows the result to directory semantics and strips the scope before callers see it.

Parameters ​

prefix ​

string

Returns ​

Promise<string[]>

Implementation of ​

StorageDriver.list


put() ​

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

Defined in: storage-gcs/src/index.ts:109

Parameters ​

path ​

string

content ​

string | Buffer<ArrayBufferLike>

options? ​

PutOptions

Returns ​

Promise<void>

Implementation of ​

StorageDriver.put


putStream() ​

> putStream(path, source, options): Promise<void>

Defined in: storage-gcs/src/index.ts:120

createWriteStream — a resumable upload GCS chunks itself, so a body of any size (and of unknown length) is uploaded without being held whole.

Parameters ​

path ​

string

source ​

Readable

options ​

PutStreamOptions

Returns ​

Promise<void>

Implementation of ​

StorageDriver.putStream


stat() ​

> stat(path): Promise<StorageStat>

Defined in: storage-gcs/src/index.ts:173

getMetadata() — size, content type, etag and last-modified without a download.

Parameters ​

path ​

string

Returns ​

Promise<StorageStat>

Implementation of ​

StorageDriver.stat


temporaryUploadUrl() ​

> temporaryUploadUrl(path, expiresInMs, options): Promise<TemporaryUploadUrl>

Defined in: storage-gcs/src/index.ts:226

Pre-signed direct upload: a V4 signed URL with action 'write'. The Content-Type is signed, and a declared contentLength is signed as x-goog-content-length-range: n,n, so GCS rejects any other type or size. checksumSha256 is refused: GCS verifies MD5/CRC32C, not SHA-256.

Parameters ​

path ​

string

expiresInMs ​

number

options ​

TemporaryUploadUrlDriverOptions

Returns ​

Promise<TemporaryUploadUrl>

Implementation of ​

StorageDriver.temporaryUploadUrl


temporaryUrl() ​

> temporaryUrl(path, expiresInMs, options?): Promise<string>

Defined in: storage-gcs/src/index.ts:208

Optional: pre-signed URL valid for expiresInMs.

Parameters ​

path ​

string

expiresInMs ​

number

options? ​

TemporaryUrlOptions

Returns ​

Promise<string>

Implementation of ​

StorageDriver.temporaryUrl

Released under the MIT License.