file-handling

Stream and validate file uploads to S3 with presigned URLs.

3|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill file-handling-mauriciodelrio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: file-handling
Source: https://github.com/mauriciodelrio/delriodev-skills/tree/main/es-skills/software/backend/file-handling
Command: npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill file-handling-mauriciodelrio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a complete, production-minded workflow for handling file uploads in Node.js backends, preventing common failures such as memory exhaustion, unvalidated content, path traversal, and uncleaned temporary files. It helps teams choose the right architecture (backend-proxied uploads vs presigned direct-to-S3) while enforcing validation, streaming, and cleanup patterns.

Core Features & Use Cases

  • Upload strategies: guidance to decide between server-side multipart uploads (multer/NestJS) and presigned S3 uploads for scalability.
  • Validation & safety: magic-bytes content validation, mimetype checks, size limits, image metadata validation with graceful cleanup on failure.
  • Streaming & storage: patterns to stream large files to S3 without buffering, serve downloads with proper headers, and run background cleanup jobs.
  • Real-world example: accept user avatars and large media efficiently by generating short-lived presigned URLs for clients, validating post-upload, and streaming processing for thumbnails.

Quick Start

Use the file-handling skill to generate a presigned S3 upload URL and validate an uploaded image 'photo.png' for user 123.

Frequently Asked Questions about file-handling

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

FAQPage Schema
How do I handle secure file uploads in Node.js without exhausting server memory?

Handle secure file uploads in Node.js by streaming files directly to S3 or disk instead of buffering, applying magic-bytes validation, and enforcing size limits to prevent memory exhaustion.

When should I use presigned S3 URLs instead of multer multipart uploads?

Use presigned S3 URLs for large media or scalable direct-to-S3 uploads, and use multer multipart uploads for smaller backend-proxied files like avatars that need server-side validation.

How do I validate file content and prevent path traversal during multipart uploads?

Validate file content during multipart uploads by checking magic bytes and mimetypes, enforcing size limits, and performing graceful temporary file cleanup on validation failure to prevent path traversal.

What is the best way to stream large files to S3 in a NestJS or Express backend?

The best way to stream large files to S3 is generating short-lived presigned URLs for direct client uploads, then streaming post-upload processing for thumbnails without buffering in memory.

Does multer support temporary file cleanup after failed image uploads?

Yes, multer supports temporary file cleanup by applying graceful cleanup patterns after failed image uploads, running background cleanup jobs to remove unvalidated files and prevent disk bloat.