QUESTPIE

Storage

File storage with Flydrive — S3, local filesystem, and upload configuration.

QUESTPIE uses Flydrive for file storage. It uses local filesystem storage by default and accepts any custom FlyDrive driver instance for S3, R2, GCS, and other backends.

Configuration

questpie.config.ts
export default runtimeConfig({
	storage: {
		basePath: "/api",
	},
});

Upload Fields

Define upload fields on collections:

avatar: f.upload({
  to: "assets",
  mimeTypes: ["image/*"],
  maxSize: 5_000_000,
}),

Storage Backends

Local (Development)

Files stored on local filesystem. Default for development.

S3 or S3-Compatible (Production)

import { S3Driver } from "flydrive/drivers/s3";

export default runtimeConfig({
	storage: {
		basePath: "/api",
		driver: new S3Driver({
			bucket: process.env.S3_BUCKET,
			region: process.env.S3_REGION,
			accessKeyId: process.env.S3_ACCESS_KEY,
			secretAccessKey: process.env.S3_SECRET_KEY,
		}),
	},
});

Cloudflare R2

R2 is S3-compatible, so use the same FlyDrive S3Driver with the R2 endpoint:

storage: {
  driver: new S3Driver({
    credentials: {
      accessKeyId: process.env.R2_ACCESS_KEY_ID!,
      secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
    },
    bucket: process.env.R2_BUCKET!,
    region: "auto",
    endpoint: `https://${process.env.CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`,
    visibility: "public",
    forcePathStyle: true,
  }),
}

For R2, use the regular FlyDrive S3 driver with Cloudflare's S3-compatible R2 endpoint.

Client Upload

// Upload a file
const asset = await client.collections.assets.upload(file, {
	onProgress: (progress) => console.log(`${progress}%`),
});
  • Media — Admin media management
  • Fields — Upload field type

On this page