Storage providers

S3, Google Cloud Storage, R2 and an in-memory adapter behind one interface — swap the provider without touching a scope.

Storage providers

A provider is the thin translation to a bucket. All three implement the same contract, so swapping one never touches the scopes or the service.

// Google Cloud Storage — two buckets: public assets, private documents
import { createGcsProvider } from 'uploaderkit/adapters/gcs'

const provider = createGcsProvider({
	publicBucket,
	privateBucket,
	publicUrl: (bucket, key) => `https://cdn.example.com/${key}`,
})
// S3-compatible — AWS, Cloudflare R2, Backblaze B2, MinIO, Wasabi
import { createS3Provider } from 'uploaderkit/adapters/s3'

const provider = createS3Provider({
	client, // an @aws-sdk/client-s3 S3Client; only endpoint/credentials differ per backend
	bucket: 'uploads',
	publicUrl: key => `https://cdn.example.com/${key}`,
})
// Tests and local development
import { createMemoryProvider } from 'uploaderkit/adapters/memory'

const provider = createMemoryProvider() // signed URLs are fake but carry the expiry

The S3 bucket is treated as private and publicUrl maps the keys a CDN or public domain exposes — modern buckets block per-object ACLs, so the adapter cannot invent a stable public URL on its own. Both SDKs are optional peers: importing an adapter without its SDK installed fails only for the app that chose that backend.

On this page