Pular para o conteúdo

Storage Configuration

Este conteúdo não está disponível em sua língua ainda.

Rebase supports two storage backends:

  • Local filesystem — Files stored on disk (great for development)
  • S3-compatible — AWS S3, MinIO, Cloudflare R2, DigitalOcean Spaces

Storage is configured in the storage block of initializeRebaseBackend:

const backend = await initializeRebaseBackend({
// ...
storage: {
type: "local",
basePath: "./uploads" // Directory for file storage
}
});
const backend = await initializeRebaseBackend({
// ...
storage: {
type: "s3",
bucket: env.S3_BUCKET!,
region: env.S3_REGION || "auto",
accessKeyId: env.S3_ACCESS_KEY_ID || "",
secretAccessKey: env.S3_SECRET_ACCESS_KEY || "",
endpoint: env.S3_ENDPOINT, // For MinIO, R2, etc.
forcePathStyle: env.S3_FORCE_PATH_STYLE // Required for MinIO
}
});

You can configure multiple named backends and route different fields to different storage:

storage: {
"(default)": { type: "local", basePath: "./uploads" },
"media": { type: "s3", bucket: "media-bucket", region: "us-east-1", ... }
}

Then in your collection properties, reference a specific backend:

image: {
type: "string",
name: "Image",
storage: {
storagePath: "products",
backend: "media" // Routes to the "media" S3 backend
}
}
MethodPathDescription
POST/api/storage/uploadUpload a file
GET/api/storage/files/:pathDownload/serve a file
DELETE/api/storage/files/:pathDelete a file
VariableDescription
STORAGE_TYPE"local" or "s3"
STORAGE_PATHLocal storage directory (default: ./uploads)
S3_BUCKETS3 bucket name
S3_REGIONAWS region (default: "auto")
S3_ACCESS_KEY_IDAWS access key
S3_SECRET_ACCESS_KEYAWS secret key
S3_ENDPOINTCustom S3 endpoint (for MinIO, R2)
S3_FORCE_PATH_STYLEUse path-style URLs (required for MinIO)
  • Mount a persistent volume if using local storage on Docker/Kubernetes
  • Use S3 or compatible (R2, MinIO) for production deployments
  • Configure a CDN (CloudFront, Cloudflare) in front of your S3 bucket for performance