samrendra.me
BackendStorageInfraactive

Protected Download Gateway

Adapter-based helper for serving private files from S3-compatible storage.

An adapter-based TypeScript / Next.js helper for serving private files from S3-compatible storage. Resolves files through application data, checks user / email / token access, then redirects to a short-lived signed storage URL.

summary

An adapter-based TypeScript / Next.js helper for serving private files from S3-compatible storage. Keeps buckets private and avoids permanent public URLs. Resolves files through application data, checks user / email / token access, then redirects to a short-lived signed URL. Supports guest downloads, public preview files, access hints, and audit-style download events. The repository and storage interfaces are pluggable — apps can wire in Prisma, Drizzle, Supabase, raw SQL, or custom APIs. Includes Vitest coverage.

highlights
  • Built an adapter-based protected download gateway for private S3-compatible files, using app-level authorization checks and short-lived signed URLs.

  • Designed access flows for paid digital downloads, guest purchases, public previews, and audited protected file delivery.

  • Implemented reusable Next.js route helpers with pluggable repository / storage adapters and test coverage.

tech
  • TypeScript
  • Next.js
  • AWS SDK v3
  • Vitest
keywords

S3 · Cloudflare R2 · signed URLs · access control · auth adapters · protected downloads · guest access · audit events

next project

up next

FFmpeg Media Worker

Node.js FFmpeg worker for thumbnails, watermarked previews, and delivery variants.

read it