feat: support multiple file uploads with the same field name#244
Closed
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
Closed
feat: support multiple file uploads with the same field name#244gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
Conversation
Add `request.files(name)` to retrieve all files matching a field name
from multipart form data. This handles `<input type="file" multiple>`
where several files share the same field name in the request body.
The existing `request.file(name)` continues to return just the first
match for backward compatibility.
- Add `getFiles()` to MultipartQuery that collects all matching files
- Add `files()` to Request as the public API wrapper
Example usage:
const uploaded = try request.files("attachments");
for (uploaded) |f| {
// f.filename, f.content
}
Closes #182
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
request.files(name)to retrieve all files matching a field name from multipart form data<input type="file" multiple>where several files share the same field nameProblem
When an HTML form uses
<input type="file" name="attachments" multiple>, the multipart request body contains multiple parts with the same field name but different filenames. The existingrequest.file("attachments")only returns the first match becauseMultipartQuery.getFile()returns on the first hit.Changes
MultipartQuery.zig: AddgetFiles()method that collects all files with a matching keyRequest.zig: Addfiles()method as the public API wrapperThe existing
request.file(name)is unchanged for backward compatibility.Usage
Test plan
zig buildsucceedszig build test --summary all- all tests passCloses #182
🤖 Generated with Claude Code