Storage

Upload, store, and serve files with a consistent API. Supports cloud object storage, Cloudflare R2, and local filesystem for development.

filesuploadsblobss3

Providers

AWS S3

Scalable object storage with global CDN and lifecycle policies

@aws-sdk/client-s3
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYS3_BUCKET

Cloudflare R2

S3-compatible object storage with zero egress fees

@aws-sdk/client-s3
R2_ACCOUNT_IDR2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEYR2_BUCKET

Local Filesystem

Local file storage for development and testing

Usage

Upload a file

Store a file using the unified storage API

import { storage } from '@/lib/storage'

const url = await storage.upload('avatars/user-123.png', file, {
  contentType: 'image/png',
  public: true,
})

Get Started

Add storage to your Primstack project with a single command:

prim storage init