Skip to content

Storage

Rebase provides integrated file storage with two backend options:

  • Local filesystem — Files stored on disk (great for development)
  • S3-compatible — AWS S3, MinIO, Cloudflare R2, DigitalOcean Spaces
await initializeRebaseBackend({
// ...
storage: {
type: "local",
basePath: "./uploads" // Directory for file storage
}
});
await initializeRebaseBackend({
// ...
storage: {
type: "s3",
bucket: "my-media-bucket",
region: "us-east-1",
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
// Optional: custom endpoint for MinIO, R2, etc.
endpoint: "https://s3.example.com"
}
});

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

storage: {
"(default)": { type: "local", basePath: "./uploads" },
"media": { type: "s3", bucket: "media-bucket", region: "us-east-1", ... }
}
MethodPathDescription
POST/api/storage/uploadUpload a file
GET/api/storage/files/:pathDownload/serve a file
DELETE/api/storage/files/:pathDelete a file

To add file uploads to your collections, use the storage property on string fields:

properties: {
image: {
type: "string",
name: "Product Image",
storage: {
storagePath: "products", // Subdirectory in storage
acceptedFiles: ["image/*"], // MIME type filter
maxSize: 5 * 1024 * 1024, // 5MB max
fileName: (context) => { // Custom filename
return context.entityId + "_" + context.file.name;
}
}
},
documents: {
type: "array",
name: "Documents",
of: {
type: "string",
storage: {
storagePath: "documents",
acceptedFiles: ["application/pdf", "image/*"]
}
}
}
}

File upload field

PropertyTypeDescription
storagePathstringSubdirectory within the storage backend
acceptedFilesstring[]Allowed MIME types (e.g., ["image/*"], ["application/pdf"])
maxSizenumberMaximum file size in bytes
fileNamefunctionCustom filename generator
metadataobjectAdditional metadata to store with the file
storeUrlbooleanStore the full URL instead of the relative path

Wrap the storage property in an array for multiple file uploads:

photos: {
type: "array",
name: "Photos",
of: {
type: "string",
storage: {
storagePath: "photos",
acceptedFiles: ["image/*"]
}
}
}

Multi file upload

For programmatic file operations:

import { useStorageSource } from "@rebasepro/core";
const storageSource = useStorageSource();
// Upload a file
const result = await storageSource.uploadFile({
file,
fileName: "my-file.pdf",
path: "documents"
});
// Get download URL
const url = await storageSource.getDownloadURL(result.path);
  • 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