Factory that creates an S3-backed object store with upload, download, and signed URL helpers.
// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import type { PutObjectCommandInput } from '@aws-sdk/client-s3'
import type { S3Environment } from './s3-config'
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
/**
* Creates one bucket-scoped client from validated startup configuration.
* Callers own authorization and object keys.
* The application must stop callers before disposal. SDK errors propagate without translation.
*/
export function createS3ObjectStore(config: S3Environment) {
const client = new S3Client({
region: config.S3_RE
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key