Add content_type property to File class#225
Open
niveshdandyan wants to merge 1 commit intoKludex:masterfrom
Open
Add content_type property to File class#225niveshdandyan wants to merge 1 commit intoKludex:masterfrom
niveshdandyan wants to merge 1 commit intoKludex:masterfrom
Conversation
This adds the ability to access the MIME type (Content-Type) of uploaded files. The Content-Type is extracted from the multipart headers when parsing file uploads and made available via the new `content_type` property on the File class. This addresses a regression compared to cgi's FieldStorage class which had a `type` attribute for the declared MIME type of uploaded files. Fixes Kludex#58 Co-Authored-By: Claude (claude-opus-4-5) <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
content_typeproperty to theFileclass to expose the MIME type of uploaded filesNoneif no Content-Type header was provided in the multipart dataFileProtocolto include the newcontent_typeparameterMotivation
This addresses issue #58 - the
Fileclass lacked MIME type information that was previously available in cgi'sFieldStorage.typeattribute. This made it difficult to properly handle uploaded files while preserving their file type.Changes
content_typeparameter toFile.__init__()content_typeproperty to expose the MIME typeFormParser.on_headers_finished()to extract and pass Content-Type header__repr__to include content_typeTest plan
File.content_typepropertyFixes #58
Note
This PR was authored with AI assistance (Claude claude-opus-4-5).
All code changes have been reviewed and tested.
🤖 Generated with Claude Code