๐—™๐—ถ๐—น๐—ฒ ๐—จ๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ ๐—”๐—ฟ๐—ฐ๐—ต๐—ถ๐˜๐—ฒ๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐—ง๐—ฎ๐—ป๐—ฆ๐˜๐—ฎ๐—ฐ๐—ธ ๐—ฆ๐˜๐—ฎ๐—ฟ๐˜ ๐—ฎ๐—ป๐—ฑ ๐—ฅ๐Ÿฎ

File upload is a core feature for any SaaS. You need to handle profile images, large documents, and media libraries.

TanStack Start on Cloudflare Workers combined with R2 storage offers a fast and cheap way to build this.

Choose your method based on file size:

โ€ข Small files (Under 5MB): Use multipart form uploads. Send files through TanStack Start server functions. This allows you to validate file types and sizes easily in one place.

โ€ข Medium files (5MB to 100MB): Use presigned URLs. The browser uploads the file directly to R2. This saves your Worker from heavy work and reduces costs.

โ€ข Large files (Over 100MB): Use chunked uploads. Break files into small pieces. This lets users pause and resume uploads without losing progress.

Why use Cloudflare R2?

The biggest advantage is zero egress fees. You do not pay when users download their files. This makes your costs predictable as you grow.

Production Checklist:

By matching your upload method to your file size, you build a system that stays fast and scales well.

Source: https://dev.to/feidou/file-upload-architecture-r2-multipart-and-streaming-in-tanstack-start-og8

Optional learning community: https://t.me/GyaanSetuAi