Skip to content

Minima.js API


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

typescript
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

ts
new S3Driver(client, options): S3Driver;

Parameters

client

S3Client

options

S3BaseDriverOptions

Returns

S3Driver

Properties

capabilities

ts
readonly capabilities: DriverCapabilities;

Optional capability declarations — see DriverCapabilities

Implementation of

DiskDriver.capabilities


client

ts
readonly client: S3Client;

name

ts
readonly name: "s3" = "s3";

Driver name (e.g., 'fs', 's3', 'azure')

Implementation of

DiskDriver.name

Accessors

[toStringTag]

Get Signature

ts
get toStringTag: string;
Returns

string

Methods

[custom]()

ts
custom: {
  [toStringTag]: string;
  bucket: string | undefined;
};

Returns

ts
{
  [toStringTag]: string;
  bucket: string | undefined;
}
[toStringTag]
ts
[toStringTag]: string;
bucket
ts
bucket: string | undefined;

copy()

ts
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

DiskDriver.copy


delete()

ts
delete(href): Promise<void>;

Delete file by href

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<void>

Implementation of

DiskDriver.delete


exists()

ts
exists(href): Promise<boolean>;

Check if file exists

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<boolean>

Implementation of

DiskDriver.exists


get()

ts
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

DiskDriver.get


list()

ts
list(prefixHref, listOptions): AsyncIterable<FileMetadata>;

List files under a prefix href.

Parameters

prefixHref

string

Absolute href prefix ending with /, or "" to list everything.

listOptions

ListOptions

Pagination options

Returns

AsyncIterable<FileMetadata>

Implementation of

DiskDriver.list


metadata()

ts
metadata(href): Promise<
  | FileMetadata
| null>;

Get file metadata without content

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise< | FileMetadata | null>

Implementation of

DiskDriver.metadata


move()

ts
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

DiskDriver.move


put()

ts
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

PutOptions

Optional metadata and content type

Returns

Promise<FileMetadata>

FileMetadata about the stored file

Implementation of

DiskDriver.put


url()

ts
url(href): Promise<string>;

Generate a URL for the file

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<string>

Implementation of

DiskDriver.url