Add UploadedFileStream PSR-7 decorator for multipart file uploads#21
Open
aviator-ua wants to merge 4 commits into
Open
Add UploadedFileStream PSR-7 decorator for multipart file uploads#21aviator-ua wants to merge 4 commits into
UploadedFileStream PSR-7 decorator for multipart file uploads#21aviator-ua wants to merge 4 commits into
Conversation
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
Adds end-to-end
multipart/form-datasupport to the request serializer:Multipart\UploadedFileStream— a PSR-7StreamInterfacedecorator that carries aSymfony
UploadedFile's filename and MIME type (exposed viagetMetadata('filename')/
getMetadata('mime-type')) alongside the underlying stream, plus agetUploadedFile()escape hatch for code needing Symfony-specific file operations.
Service\Serializer\Normalizer\StreamInterfaceDenormalizer— passesStreamInterfacevalues through denormalization untouched, so binary DTO properties survive the request
serializer instead of being mangled.
Context
Part of the rollout to support
multipart/form-dataacross the auto1-oss API stack.Changes
Multipart/UploadedFileStream.php— new PSR-7 decorator (see Summary).Service/Serializer/Normalizer/StreamInterfaceDenormalizer.php— new pass-through denormalizer.Resources/config/symfony_services.yml— registers the new denormalizer inauto1.api.request.serializer; migrates serializer service definitions to named arguments;sets
parent: serializer.encoder.jsonon the JSON encoder; wiresserializer.name_converter.metadata_awareinto the object normalizer; passes the datetimeformat via
defaultContext.composer.json— addspsr/http-messageandsymfony/http-foundationdependencies.Service/Logger/LoggerAwareTrait.php— adds license header;setLogger()now returnsvoid.Tests/Multipart/UploadedFileStreamTest.php,Tests/Serializer/Normalizer/StreamInterfaceDenormalizerTest.php.Architectural notes
Location
Placed at top-level
Multipart/rather thanService/Multipart/. The class is a statefulper-request wrapper, not a DI-registered service — grouping by domain (like Symfony's
HttpFoundation\File\UploadedFile) reads more accurately than appending toService/.No factory
Construction is a single line at one call site today (
MultipartRequestDataExtractor::wrapFiles,in the handler bundle). A factory would just relocate the PSR-17
StreamFactoryInterfacedependency one layer deeper without removing duplication. Worth revisiting if a second call
site appears or if construction grows real logic.
Open question
The handler-bundle's extractor recursively walks nested file arrays (
<input name="foo[bar]">shape). Generated DTOs currently declare each binary property as a flat top-level
StreamInterface, so the nested walk is defensive for now.