mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
2d163bb600
* Initial plan * Rename dotnet-aspnet plugin to dotnet-aspnetcore --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
52 lines
2.9 KiB
YAML
52 lines
2.9 KiB
YAML
scenarios:
|
|
- name: "Implement secure file upload in ASP.NET Core 8 minimal API"
|
|
prompt: |
|
|
I need to implement a file upload endpoint in my ASP.NET Core 8 minimal API.
|
|
The endpoint should accept image files (JPEG and PNG only), reject files over 10MB,
|
|
and save them to an "uploads" folder. My app already has UseAntiforgery() in the pipeline.
|
|
Show me the complete implementation including size limits configuration and the endpoint.
|
|
assertions:
|
|
- type: "output_matches"
|
|
pattern: "(IFormFile|IFormFileCollection)"
|
|
- type: "output_matches"
|
|
pattern: "(Guid\\.NewGuid|Path\\.GetRandomFileName)"
|
|
rubric:
|
|
- "Configures both the Kestrel request body size limit and the form multipart body length limit — not just one of them"
|
|
- "Handles the antiforgery middleware that would otherwise reject the upload with a 400 error"
|
|
- "Does not save to disk using the original user-provided filename — generates a safe name to prevent path traversal"
|
|
- "Verifies the actual file content (e.g., magic bytes or file signatures), not just the Content-Type header which can be spoofed"
|
|
timeout: 180
|
|
|
|
- name: "Upload multiple files with metadata in minimal API"
|
|
prompt: |
|
|
Show me how to add a file upload endpoint to an ASP.NET Core 8 minimal API
|
|
that accepts multiple image files along with a text description field from
|
|
the same form submission. The total size can be up to 50MB. Just show me
|
|
the code — I don't need a full project.
|
|
assertions:
|
|
- type: "output_matches"
|
|
pattern: "(IFormFileCollection|IFormFile|List<IFormFile>)"
|
|
- type: "output_matches"
|
|
pattern: "(MaxRequestBodySize|MultipartBodyLengthLimit)"
|
|
rubric:
|
|
- "Configures both the Kestrel request body size limit and the form multipart body length limit for the 50MB requirement"
|
|
- "Uses [FromForm] correctly when mixing file parameters with non-file form fields like description"
|
|
- "Does not save uploaded files using the original user-provided filenames"
|
|
timeout: 180
|
|
|
|
- name: "Stream very large file uploads without buffering"
|
|
prompt: |
|
|
I need to accept uploads of video files up to 2GB in my ASP.NET Core 8 minimal API.
|
|
Using IFormFile crashes with out-of-memory errors for files over 500MB.
|
|
How do I stream large uploads directly to disk without buffering the whole file?
|
|
assertions:
|
|
- type: "output_matches"
|
|
pattern: "(MultipartReader|ReadNextSectionAsync)"
|
|
- type: "output_matches"
|
|
pattern: "(DisableRequestSizeLimit|MaxRequestBodySize)"
|
|
rubric:
|
|
- "Uses MultipartReader to stream upload sections directly to disk instead of buffering via IFormFile"
|
|
- "Disables or increases the request size limit to accommodate 2GB files"
|
|
- "Does not use the user-provided filename directly when saving streamed sections to disk"
|
|
timeout: 180
|