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
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
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?
Returns
Promise<void>
Implementation of
delete()
> delete(path): Promise<boolean>
Defined in: storage-gcs/src/index.ts:197
Parameters
path
string
Returns
Promise<boolean>
Implementation of
disconnect()
> disconnect(): Promise<void>
Defined in: storage-gcs/src/index.ts:259
Returns
Promise<void>
Implementation of
exists()
> exists(path): Promise<boolean>
Defined in: storage-gcs/src/index.ts:192
Parameters
path
string
Returns
Promise<boolean>
Implementation of
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
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
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
put()
> put(path, content, options?): Promise<void>
Defined in: storage-gcs/src/index.ts:109
Parameters
path
string
content
string | Buffer<ArrayBufferLike>
options?
Returns
Promise<void>
Implementation of
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
Returns
Promise<void>
Implementation of
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
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?
Returns
Promise<string>