protected-file-delivery

Generate 60-second presigned URLs for authenticated file downloads on Next.js SaaS platforms.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/raingernx/KRUKRAFT --skill protected-file-delivery
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: protected-file-delivery
Source: https://github.com/raingernx/KRUKRAFT/tree/main/.claude/skills/protected-file-delivery
Command: npx skills add https://github.com/raingernx/KRUKRAFT --skill protected-file-delivery

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevent unauthorized access to private files by eliminating direct exposure of storage keys.

Core Features & Use Cases

  • Gate private file downloads via a server-side API, ensuring only authenticated users with valid purchases or subscriptions can access resources.
  • Generate short-lived pre-signed URLs to private Cloudflare R2 objects, preventing long-lived links.
  • Never expose R2 file keys to clients; all lookups occur server-side via resourceId, with strict access checks.

Quick Start

Audit your download flow by verifying session checks, DB lookups for file keys, and a presigned URL expiry of 60 seconds.

Frequently Asked Questions about protected-file-delivery

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure private file downloads in a Next.js SaaS application?

To secure private file downloads in a Next.js SaaS application, implement server-side API routes for session validation and access checks, generating short-lived presigned URLs to prevent unauthorized access and direct storage key exposure.

How do presigned URLs prevent unauthorized access to Cloudflare R2 files?

Presigned URLs prevent unauthorized access by providing short-lived links to Cloudflare R2 files. This approach generates 60-second presigned URLs via a 302 redirect, ensuring expired links cannot be reused and original storage keys remain hidden from clients.

Can I gate file downloads based on user purchases and subscriptions in Next.js?

Yes, you can gate file downloads based on user purchases and subscriptions in Next.js. This approach performs server-side database lookups using a resourceId to verify active subscriptions or purchases before issuing a short-lived presigned download URL.

What is the best way to hide storage keys when serving private files?

The best way to hide storage keys when serving private files is to eliminate direct client exposure entirely. Perform server-side resource lookups using a generic resourceId, validate user access, then return a 302 redirect to a short-lived presigned URL.

Why use a 60-second presigned URL for private file delivery?

A 60-second presigned URL for private file delivery ensures links expire almost immediately, preventing users from sharing long-lived access. Combined with server-side session validation, it strictly controls downloads to authenticated users with valid access rights.

How do I audit an existing Next.js download flow for security vulnerabilities?

To audit a Next.js download flow for security vulnerabilities, verify that session checks are enforced, database lookups map generic resourceIds to file keys safely, and presigned URL expiry is set to a short duration to prevent link sharing.