minimal-api-file-upload

Secure ASP.NET Minimal API file uploads with IFormFile validation and streaming.

Updated Aug 16, 2025
One-click install
npx skills add https://github.com/dodyg/blue-nile-pds --skill minimal-api-file-upload
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: minimal-api-file-upload
Source: https://github.com/dodyg/blue-nile-pds/tree/main/.agents/skills/dotnet-aspnet/skills/minimal-api-file-upload
Command: npx skills add https://github.com/dodyg/blue-nile-pds --skill minimal-api-file-upload

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides guidance for implementing and securing file upload endpoints in ASP.NET Core Minimal APIs, addressing common pitfalls and best practices.

Core Features & Use Cases

  • IFormFile binding and handling for single and multiple files in Minimal APIs.
  • Comprehensive guidance on configuring size limits (Kestrel and form options) and per-endpoint overrides.
  • Anti-forgery considerations and how to opt out for API endpoints, with safety warnings.
  • Validation of content type and file signature, safe filename generation, and secure storage.
  • Streaming large uploads with MultipartReader to avoid buffering.

Quick Start

Create a minimal API endpoint to accept file uploads via IFormFile, validate type and size, and store safely.

Frequently Asked Questions about minimal-api-file-upload

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

FAQPage Schema
How do I handle file uploads in ASP.NET Minimal APIs using IFormFile?

Secure file uploads in ASP.NET Minimal APIs by validating IFormFile content types, enforcing Kestrel size limits, generating safe filenames, and protecting against path traversal and content spoofing attacks during storage.

How do I validate file content type and prevent path traversal in ASP.NET Core file uploads?

Validate file content type and prevent path traversal in ASP.NET Core file uploads by checking file signatures, generating safe filenames, and applying explicit validation rules before storing the uploaded IFormFile data.

How do I stream large file uploads in ASP.NET Core Minimal APIs without buffering?

Stream large file uploads in ASP.NET Core Minimal APIs without buffering by using MultipartReader, which processes the request stream directly and avoids loading large files into server memory.

Do I need antiforgery tokens for file upload endpoints in ASP.NET Minimal APIs?

Antiforgery tokens for file upload endpoints in ASP.NET Minimal APIs are required by default, but you can opt out for API endpoints with explicit safety warnings to allow non-browser client access.

How do I configure file upload size limits in Kestrel and ASP.NET Minimal API endpoints?

Configure file upload size limits in Kestrel and form options globally, then apply per-endpoint overrides in ASP.NET Minimal APIs to control the maximum accepted IFormFile size for specific routes.