Skip to content

Refactor image upload structure #16

Description

@slytter

Current Problem

Uploads are broken in production due to Vercel serverless limitations:

  • 413 FUNCTION_PAYLOAD_TOO_LARGE: Vercel enforces 4.5MB request body limit at infrastructure level
  • 503 SERVICE_UNAVAILABLE: Remix's unstable_parseMultipartFormData crashes with multiple files on Vercel
  • Memory issues: Buffering approach (request.formData()) hits memory limits with large files

Current workaround: Upload 1 file at a time with batch size = 1 (slow but works)

Proposed Solution

Implement direct client-to-BunnyCDN uploads with a two-phase storage strategy:

Phase 1: Temporary Upload (Draft)

  • Client uploads directly to BunnyCDN (bypasses Vercel limits entirely)
  • Files stored in a temp/ folder with 24h TTL
  • Use short-lived signed URLs or similar for security
  • Returns CDN URL immediately for preview

Phase 2: Persist on Save (Authenticated)

  • When user saves project (authenticated), server moves files from temp/ to permanent storage
  • Only persisted files count against storage quota
  • Unused temp files auto-delete after 24h

Benefits

  • No file size limits
  • Faster uploads (direct to CDN)
  • No Vercel memory/timeout issues
  • Clean up abandoned uploads automatically
  • Better UX (instant preview)

Tasks

  • Research BunnyCDN options for temporary storage / signed URLs
  • Implement client-side direct upload
  • Create server endpoint for persisting files on project save
  • Set up cleanup for expired temp files
  • Update create.upload.tsx to use new flow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions