upload-stuff

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

OptionControlsOverride when
storageAdapter / databaseAdapterWhere file bytes and file rows live — see the S3 and Prisma adaptersYou target a different object store or ORM
fileIdGeneratorFile row IDsYour database needs a specific ID format
fileKeyGeneratorStorage object keysKeys should follow your own path convention
filePublicUrlGeneratorPublic URLs persisted per filePublic files are served through a CDN or custom domain
fieldsCustom columns persisted with each file, resolved per upload by .fields()Your File table carries app columns like userId
uploadWindowSecondsPresigned URL expiry, completion deadline, and cleanup thresholdThe default 3600 is too short or too long for your uploads
defaultMaxFileCount / defaultMaxFileSizeFallback route limitsMost 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.

Next steps

On this page