Codapult
ЦеныПлагиныДокументация
Codapult

SaaS-бойлерплейт для разработчиков

Продукт

  • Цены
  • Плагины
  • Документация

Компания

  • Контакты
  • GitHub

Правовая информация

  • Политика конфиденциальности
  • Условия использования

© 2026 Codapult. Все права защищены.

Все статьи

Getting Started

  • Introduction
  • Quick Start
  • Project Structure

Configuration

  • Environment Variables
  • App Configuration

Authentication

  • Authentication
  • OAuth Providers
  • Two-Factor & Passwordless
  • Enterprise SSO (SAML)

Database

  • Database
  • Migrations

Teams

  • Teams & Organizations
  • Permissions & RBAC

Payments

  • Payments & Billing
  • Stripe Setup
  • LemonSqueezy Setup
  • Polar Setup
  • Payment Webhooks

Api

  • API Layer
  • tRPC
  • GraphQL

Ai

  • AI Features

Email

  • Email
  • Email Templates

Infrastructure

  • Infrastructure
  • File Storage
  • Background Jobs

Ui

  • UI & Theming

I18n

  • Internationalization

Content Management

  • Content Management

Admin

  • Admin Panel

Security

  • Security

Monitoring

  • Analytics & Monitoring

Modules

  • Module Architecture

Plugins

  • Plugin System
  • AI Kit Plugin
  • CRM Plugin
  • Helpdesk Plugin
  • Email Marketing Plugin

Deployment

  • Deployment
  • Troubleshooting

Upgrading

  • Upgrading Codapult

Developer Tools

  • MCP Server
  • Testing
Infrastructure

File Storage

Upload and serve files with local, S3, or Cloudflare R2 storage adapters.

Upload and serve files through a unified API. The storage adapter is selected by STORAGE_PROVIDER.

Providers

ProviderEnv ValueBest For
Local filesystemlocal (default)Development
Amazon S3s3Production (AWS)
Cloudflare R2r2Production (Cloudflare)

Upload API

POST /api/upload accepts multipart form data. Authentication is required.

const form = new FormData();
form.append('file', file);

const res = await fetch('/api/upload', {
  method: 'POST',
  body: form,
});

const { url } = await res.json();

Image uploads are automatically optimized (resized, compressed) before storage.

Switching to S3 or R2

  1. Install the AWS SDK:
pnpm add @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
  1. Set the provider and credentials in .env.local:
STORAGE_PROVIDER="s3"   # or "r2"

S3_BUCKET="my-bucket"
S3_REGION="us-east-1"   # use "auto" for R2
S3_ENDPOINT=""           # required for R2 (e.g. https://<account>.r2.cloudflarestorage.com)
S3_ACCESS_KEY_ID="..."
S3_SECRET_ACCESS_KEY="..."
S3_PUBLIC_URL=""         # optional — public URL prefix for uploaded files

Production: Always use S3 or R2. The local adapter stores files on disk and is not suitable for multi-instance deployments.

Programmatic Usage

import { uploadFile, deleteFile } from '@/lib/storage';

const url = await uploadFile('avatars/user-123.webp', buffer, 'image/webp');
await deleteFile('avatars/user-123.webp');

Environment Variables

VariableRequiredDescription
STORAGE_PROVIDERNo"local" (default), "s3", or "r2"
S3_BUCKETYes*S3 bucket name
S3_REGIONNoAWS region. Defaults to "auto" (required for R2)
S3_ENDPOINTYes**Custom S3 endpoint URL (required for R2 and S3-compatible providers)
S3_ACCESS_KEY_IDYes*Access key ID
S3_SECRET_ACCESS_KEYYes*Secret access key
S3_PUBLIC_URLNoPublic URL prefix for uploaded files (e.g. CDN domain)

* Required when STORAGE_PROVIDER=s3 or r2. ** Required for Cloudflare R2 and other S3-compatible providers.

InfrastructureBackground Jobs