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
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
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?
Returns
Promise<void>
Implementation of
delete()
> delete(path): Promise<boolean>
Defined in: storage-s3/src/index.ts:466
Parameters
path
string
Returns
Promise<boolean>
Implementation of
disconnect()
> disconnect(): Promise<void>
Defined in: storage-s3/src/index.ts:553
Returns
Promise<void>
Implementation of
exists()
> exists(path): Promise<boolean>
Defined in: storage-s3/src/index.ts:456
Parameters
path
string
Returns
Promise<boolean>
Implementation of
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
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
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
put()
> put(path, content, options?): Promise<void>
Defined in: storage-s3/src/index.ts:267
Parameters
path
string
content
string | Buffer<ArrayBufferLike>
options?
Returns
Promise<void>
Implementation of
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:
contentLengthis known — the stream goes straight toPutObject, nothing is buffered (this is whatfiles.upload()does when the client sends aContent-Length). The Disk layer verifies the body carries exactly that many bytes;- it is not — multipart upload, when the optional peer
@aws-sdk/lib-storageis installed: the body is uploaded part by part, holding at mostpartSizeBytes × queueSizeat a time WHATEVERmaxBytessays (a body smaller than one part goes as a singlePutObjectof that part).maxBytesstays 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
Returns
Promise<void>
Implementation of
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
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?
Returns
Promise<string>