Skip to content

basalt / storage-s3/src / S3StorageDriver

Class: S3StorageDriver ​

Defined in: storage-s3/src/index.ts:209

S3-compatible driver — works with AWS S3, MinIO, Cloudflare R2, etc.

Implements ​

Constructors ​

Constructor ​

> new S3StorageDriver(options): S3StorageDriver

Defined in: storage-s3/src/index.ts:221

Parameters ​

options ​

S3DriverOptions

Returns ​

S3StorageDriver

Properties ​

name ​

> readonly name: "s3" = 's3'

Defined in: storage-s3/src/index.ts:210

Human-readable driver name — used in error messages.

Implementation of ​

StorageDriver.name

Methods ​

copy() ​

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

Defined in: storage-s3/src/index.ts:422

CopyObject: S3 moves the bytes, they 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-s3/src/index.ts:466

Parameters ​

path ​

string

Returns ​

Promise<boolean>

Implementation of ​

StorageDriver.delete


disconnect() ​

> disconnect(): Promise<void>

Defined in: storage-s3/src/index.ts:553

Returns ​

Promise<void>

Implementation of ​

StorageDriver.disconnect


exists() ​

> exists(path): Promise<boolean>

Defined in: storage-s3/src/index.ts:456

Parameters ​

path ​

string

Returns ​

Promise<boolean>

Implementation of ​

StorageDriver.exists


get() ​

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

Defined in: storage-s3/src/index.ts:389

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-s3/src/index.ts:403

The GetObject body, as a Node Readable. The caller must consume or destroy it.

Parameters ​

path ​

string

Returns ​

Promise<Readable>

Implementation of ​

StorageDriver.getStream


list() ​

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

Defined in: storage-s3/src/index.ts:474

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-s3/src/index.ts:267

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-s3/src/index.ts:302

Streams a body into S3.

PutObject cannot send a body of unknown length in a single request, so the route depends on what the caller knows:

  • contentLength is known — the stream goes straight to PutObject, nothing is buffered (this is what files.upload() does when the client sends a Content-Length). The Disk layer verifies the body carries exactly that many bytes;
  • it is not — multipart upload, when the optional peer @aws-sdk/lib-storage is installed: the body is uploaded part by part, holding at most partSizeBytes × queueSize at a time WHATEVER maxBytes says (a body smaller than one part goes as a single PutObject of that part). maxBytes stays a limit, enforced by the Disk mid-stream; it is never a buffer size.

Without @aws-sdk/lib-storage an unknown length can only be sent as one buffered PutObject: with maxBytes the body is collected up to that cap (so up to maxBytes in memory — install the peer to avoid it), and with neither option the call fails with StorageStreamLengthRequiredError, which names the package.

Parameters ​

path ​

string

source ​

Readable

options ​

S3PutStreamOptions

Returns ​

Promise<void>

Implementation of ​

StorageDriver.putStream


stat() ​

> stat(path): Promise<StorageStat>

Defined in: storage-s3/src/index.ts:441

HeadObject: 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-s3/src/index.ts:514

Pre-signed PutObject. Content-Type — and Content-Length, the SHA-256 checksum and the SSE headers when present — are signed as HEADERS (not hoisted into the query string), so S3 rejects an upload that omits or changes any of them: the client cannot swap the type, grow the body or skip encryption. With checksumSha256, S3 also verifies the body itself.

Parameters ​

path ​

string

expiresInMs ​

number

options ​

TemporaryUploadUrlDriverOptions

Returns ​

Promise<TemporaryUploadUrl>

Implementation of ​

StorageDriver.temporaryUploadUrl


temporaryUrl() ​

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

Defined in: storage-s3/src/index.ts:493

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.