Utsuk
INTERNAL · PREVIEWRegistryTheme GeneratorGitHub
Accelerators / File Upload

File Upload Accelerator

Spec-aligned generator for `utsuk.config.ts` + live preview.

01 — File Rules
Examples
Typical production allowlist: .pdf,.jpg,.png. Use * only for internal tools (pair with strong server-side checks).
02 — Upload
Examples
Presign env var: NEXT_PUBLIC_PRESIGN_URL
Timeout: 300s for ~10MB on typical networks (increase for larger files / mobile).
Concurrency: 2–3 to avoid saturating mobile connections.
03 — Presentation
Examples
Drag-drop UX (recommended): label Drop files here, sub-label PDF/JPG/PNG, button Browse.
04 — Styling
Examples
Primary color: #2563eb (Tailwind blue-600)
Border radius: 10px
CSS variables: {"--utsuk-fu-radius":"12px"}
05 — Server: S3
Examples
AWS: region ap-south-1, endpoint unset.
R2: region auto, endpoint https://<accountid>.r2.cloudflarestorage.com, checksum disabled.
MinIO: endpoint http://localhost:9000, force path style true.
06 — Server: Routes and guards
Examples
Routes: /upload/presign + /upload/url
CORS origins env var: CORS_ORIGINS = https://app.yourapp.com
Auth (recommended): header mode with authorization
Rate limit: 30 requests / minute (tune per product).
Live preview
Drop files here
PDF/JPG/PNG
Output
// File Upload Accelerator — full utsuk.config.ts
//
// No @utsuk/core wrapper; exports a plain object for maximum compatibility.

export default {
  accelerators: {
    "@utsuk/file-upload": {
          fileUpload: {
            accepted_file_types: [".pdf", ".jpg", ".png"],
            allow_multiple: true,
            max_file_size: 10 * 1024 * 1024,
            max_files: 5,
            max_total_size: 50 * 1024 * 1024,
            reject_empty_files: true,
            file_preview: false,
        
            background_upload: true,
            // change the 'process.env' with your environment variable based on env(eg: 'import.meta.env.VITE_PRESIGN_URL' etc..) 
            upload_url: process.env.NEXT_PUBLIC_PRESIGN_URL,
            upload_timeout_ms: 300 * 1000,
                upload_retry: { max_attempts: 3, initial_delay_ms: 1000 },
            upload_concurrency: 3,
        
            drag_drop: true,
            drag_drop_config: {
              label: "Drop files here",
              sub_label: "PDF/JPG/PNG",
              button_text: "Browse",
            },
            button_type: "button",
            button_text: "Upload file",
            max_width: "100%",
            compact_breakpoint_px: 480,
            aria_label: "File upload",
          },
        },
      },

    "@utsuk/file-upload-server": {
          s3: {
            bucket: process.env.S3_BUCKET,
            access_key_id: process.env.S3_ACCESS_KEY_ID,
            secret_access_key: process.env.S3_SECRET_ACCESS_KEY,
            region: process.env.S3_REGION,
            endpoint: process.env.S3_ENDPOINT,
            force_path_style: false,
            disable_request_checksum_calculation: false,
            key_prefix: "uploads",
            presigned_upload_ttl: 300,
            presigned_download_ttl: 3600,
          },
          max_file_size: 10 * 1024 * 1024,
          accepted_file_types: [".pdf", ".jpg", ".png"],
          cors_origins: process.env.CORS_ORIGINS?.split(",") ?? ["http://localhost:3000"],
          upload_route: "/upload/presign",
          download_route: "/upload/url",
          strict_filename_validation: true,
          rate_limit: { window_ms: 60000, max_requests: 30 },
          auth: { mode: "header", header_name: "authorization" },
        },
      },
  },
};