Configuration
Configure the UploadStuff instance, adapters, fields, upload windows, defaults, and server utilities.
An UploadStuff instance owns your adapters, generators, and route defaults.
Create an instance
import { UploadStuff } from "@upload-stuff/server";
import { s3Adapter } from "@upload-stuff/server/adapters/s3";
import { prismaAdapter } from "@upload-stuff/server/adapters/prisma";
import { prisma } from "./db";
export const uploadStuff = UploadStuff({
storageAdapter: s3Adapter({ config: { region: "us-east-1" }, bucket: "my-bucket" }),
databaseAdapter: prismaAdapter({ prisma }),
filePublicUrlGenerator: ({ key }) => `https://cdn.example.com/${key}`,
});Options
| Option | Controls | Override when |
|---|---|---|
storageAdapter / databaseAdapter | Where file bytes and file rows live — see the S3 and Prisma adapters | You target a different object store or ORM |
fileIdGenerator | File row IDs | Your database needs a specific ID format |
fileKeyGenerator | Storage object keys | Keys should follow your own path convention |
filePublicUrlGenerator | Public URLs persisted per file | Public files are served through a CDN or custom domain |
fields | Custom columns persisted with each file, resolved per upload by .fields() | Your File table carries app columns like userId |
uploadWindowSeconds | Presigned URL expiry, completion deadline, and cleanup threshold | The default 3600 is too short or too long for your uploads |
defaultMaxFileCount / defaultMaxFileSize | Fallback route limits | Most routes share limits other than 20 files / 4MB |
For the exhaustive option table, see the server reference.
Server utilities
Every instance exposes serverUtils.cleanUpFiles(), serverUtils.uploadFile({ data, content }), and serverUtils.deleteFiles(fileIds) for server-side file work outside the browser upload lifecycle. See Out-of-band file operations for examples.