IFormFile represents a file uploaded through an HTTP form. ASP.NET Core recognizes it as a special binding type and populates it with the uploaded file’s metadata and content access. section 7.6 section 7.6.3
Use the interface to access:
- FileName, the client-provided filename, which must not be trusted or used directly for storage. section 7.6.3
- ContentType and Length, which describe the uploaded content. section 7.6.3
- OpenReadStream(), which provides access to the buffered file contents. section 7.6.3
- IFormFileCollection, IEnumerable<IFormFile>, or List<IFormFile> when multiple files are accepted. section 7.6.3 section 16.2.2
Minimal API upload parameter
An endpoint can declare IFormFile directly: app.MapGet("/upload", (IFormFile file) => {}); ASP.NET Core binds the uploaded file to the handler parameter. For larger uploads, the default approach can consume memory or disk because the complete file is buffered before the handler receives it; streaming may be necessary instead. section 7.6.3
