Minima.js API / @minimajs/aws-s3 / S3Driver
Class: S3Driver
AWS S3 storage driver for @minimajs/disk
Provides a web-native File API interface for AWS S3, eliminating the need to learn AWS SDK methods.
Example
import { S3Driver } from '@minimajs/aws-s3';
import { createDisk } from '@minimajs/disk';
const driver = new S3Driver({
bucket: 'my-bucket',
region: 'us-east-1',
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
},
publicUrl: 'https://d1234.cloudfront.net',
storageClass: 'STANDARD_IA',
});
const disk = createDisk({ driver });
// Web-native API - works like browser File API
const file = new File(['content'], 'test.txt');
await disk.put(file); // Auto-generates filename
await disk.put('photos/sunset.jpg', imageBuffer);
const retrieved = await disk.get('photos/sunset.jpg');
const arrayBuffer = await retrieved.arrayBuffer(); // Standard File.arrayBuffer()Implements
Constructors
Constructor
new S3Driver(client, options): S3Driver;Parameters
client
S3Client
options
Returns
S3Driver
Properties
capabilities
readonly capabilities: DriverCapabilities;Optional capability declarations — see DriverCapabilities
Implementation of
client
readonly client: S3Client;name
readonly name: "s3" = "s3";Driver name (e.g., 'fs', 's3', 'azure')
Implementation of
Accessors
[toStringTag]
Get Signature
get toStringTag: string;Returns
string
Methods
[custom]()
custom: {
[toStringTag]: string;
bucket: string | undefined;
};Returns
{
[toStringTag]: string;
bucket: string | undefined;
}[toStringTag]
[toStringTag]: string;bucket
bucket: string | undefined;copy()
copy(from, to): Promise<void>;Copy a file to a new location
Parameters
from
string
Source absolute URL/URI
to
string
Destination absolute URL/URI
Returns
Promise<void>
Implementation of
delete()
delete(href): Promise<void>;Delete file by href
Parameters
href
string
Absolute URL/URI with protocol
Returns
Promise<void>
Implementation of
exists()
exists(href): Promise<boolean>;Check if file exists
Parameters
href
string
Absolute URL/URI with protocol
Returns
Promise<boolean>
Implementation of
get()
get(href): Promise<
| [ReadableStream<Uint8Array<ArrayBufferLike>>, FileMetadata]
| null>;Retrieve file as a ReadableStream with metadata
Parameters
href
string
Absolute URL/URI with protocol
Returns
Promise< | [ReadableStream<Uint8Array<ArrayBufferLike>>, FileMetadata] | null>
Tuple of [stream, metadata] or null if not found
Implementation of
list()
list(prefixHref, listOptions): AsyncIterable<FileMetadata>;List files under a prefix href.
Parameters
prefixHref
string
Absolute href prefix ending with /, or "" to list everything.
listOptions
Pagination options
Returns
AsyncIterable<FileMetadata>
Implementation of
metadata()
metadata(href): Promise<
| FileMetadata
| null>;Get file metadata without content
Parameters
href
string
Absolute URL/URI with protocol
Returns
Promise< | FileMetadata | null>
Implementation of
move()
move(from, to): Promise<void>;Move a file to a new location
Parameters
from
string
Source absolute URL/URI
to
string
Destination absolute URL/URI
Returns
Promise<void>
Implementation of
put()
put(
href,
stream,
putOptions): Promise<FileMetadata>;Store data from a ReadableStream
Parameters
href
string
Absolute URL/URI with protocol
stream
ReadableStream<Uint8Array<ArrayBufferLike>>
ReadableStream of data to store
putOptions
Optional metadata and content type
Returns
Promise<FileMetadata>
FileMetadata about the stored file
Implementation of
url()
url(href): Promise<string>;Generate a URL for the file
Parameters
href
string
Absolute URL/URI with protocol
Returns
Promise<string>