Skip to content

@storyshelf/storage-s3

View as Markdown

@storyshelf/storage-s3 stores StoryShelf blobs in an S3-compatible object store. It supports AWS S3, Cloudflare R2, MinIO, and DigitalOcean Spaces.

Terminal window
npm i @storyshelf/storage-s3

JSR JSR Score

import { createS3Storage } from "@storyshelf/storage-s3";
import { createShelfApp } from "@storyshelf/app";
const storage = createS3Storage({
bucket: "my-shelf",
prefix: "storyshelf",
endpoint: process.env.S3_ENDPOINT, // optional, e.g. for MinIO/R2
region: "us-east-1", // optional
});
const app = createShelfApp({ database, storage });
interface S3StorageOptions {
bucket: string; // required bucket name
prefix?: string; // optional key prefix, defaults to ""
endpoint?: string; // optional custom endpoint (MinIO, R2, etc.)
region?: string; // optional region, defaults to "us-east-1"
}

createS3Storage(options: S3StorageOptions): StorageAdapter

Section titled “createS3Storage(options: S3StorageOptions): StorageAdapter”

Creates an S3 client (with forcePathStyle enabled for compatibility with MinIO/R2) and returns a StorageAdapter. The returned adapter implements every method of the StorageAdapter interface (read, write, delete, exists, list(prefix)).

s3Key(prefix: string, path: string): string

Section titled “s3Key(prefix: string, path: string): string”

Helper that joins a storage prefix with a relative path into an object key.

Choose S3 storage for cloud or multi-node deployments. It is a drop-in replacement for local storage, and pairs naturally with the Turso preset when the application is deployed without shared local disk.