Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Introduce#[MapUploadedFile] controller argument attribute#49978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chalasr merged 1 commit intosymfony:7.1fromrenedelima:map-uploaded-file
Apr 18, 2024

Conversation

@renedelima
Copy link
Contributor

@renedelimarenedelima commentedApr 8, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
Tickets#52678,#49138
LicenseMIT
Doc PR-

Usage Example

# src/Controller/UserPictureController.phpnamespaceApp\Controller;useSymfony\Component\HttpFoundation\File\UploadedFile;useSymfony\Component\HttpFoundation\Response;useSymfony\Component\HttpKernel\Attribute\AsController;useSymfony\Component\HttpKernel\Attribute\MapUploadedFile;useSymfony\Component\Routing\Annotation\Route;useSymfony\Component\Validator\ConstraintsasAssert;#[AsController]finalclass UserPictureController{    #[Route('/user/picture', methods: ['PUT'])]publicfunction__invoke(        #[MapUploadedFile(newAssert\File(mimeTypes: ['image/png','image/jpeg']),        )] ?UploadedFile$picture,    ):Response {returnnewResponse('Your picture was updated');    }}
# src/Controller/UserDocumentsController.phpnamespaceApp\Controller;useSymfony\Component\HttpFoundation\Response;useSymfony\Component\HttpKernel\Attribute\AsController;useSymfony\Component\HttpKernel\Attribute\MapUploadedFile;useSymfony\Component\Routing\Annotation\Route;useSymfony\Component\Validator\ConstraintsasAssert;finalclass UserDocumentsController{    #[Route('/user/documents', methods: ['PUT'])]publicfunction__invoke(        #[MapUploadedFile(newAssert\File(mimeTypes: ['application/pdf'])        )]array$documents    ):Response {returnnewResponse('Thanks for sharing your documents');    }}
# src/Controller/UserDocumentsController.phpnamespaceApp\Controller;useSymfony\Component\HttpFoundation\File\UploadedFile;useSymfony\Component\HttpFoundation\Response;useSymfony\Component\HttpKernel\Attribute\AsController;useSymfony\Component\HttpKernel\Attribute\MapUploadedFile;useSymfony\Component\Routing\Annotation\Route;useSymfony\Component\Validator\ConstraintsasAssert;finalclass UserDocumentsController{    #[Route('/user/documents', methods: ['PUT'])]publicfunction__invoke(        #[MapUploadedFile(newAssert\File(mimeTypes: ['application/pdf'])        )]UploadedFile ...$documents    ):Response {returnnewResponse('Thanks for sharing your documents');    }}

renanbr, valtzu, ElGovanni, jurchiks, cheike569, solverat, tanukijs, asrorbekh, BoShurik, zmitic, and 2 more reacted with thumbs up emojiKoc and sstok reacted with rocket emoji
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@renedelimarenedelimaforce-pushed themap-uploaded-file branch 3 times, most recently from66e8f09 tof366d35CompareApril 8, 2023 19:08
@Koc
Copy link
Contributor

Koc commentedApr 11, 2023
edited
Loading

Wow, I like idea of reusing infrastructure provided byRequestPayloadValueResolver 👏

Can you add support of the variadic arguments? + squash your commits for easier review until my PR hasn't merged.

renedelima, GromNaN, and flomSStaar reacted with thumbs up emoji

@renedelima
Copy link
ContributorAuthor

Can you add support of the variadic arguments? + squash your commits for easier review until my PR hasn't merged.

I Just added support to variadic arguments and the commits were squashed.@Koc

A missing file is like a missing form field in the payload. The code should be 422 too.

Status code changed to 422.@GromNaN

Koc reacted with hooray emoji

@Koc
Copy link
Contributor

Koc commentedApr 14, 2023

@renedelima you can rebase now 🎉

renedelima reacted with thumbs up emoji

@renedelimarenedelimaforce-pushed themap-uploaded-file branch 8 times, most recently from75aad23 to9eb9b53CompareApril 18, 2023 16:15
@renedelima
Copy link
ContributorAuthor

@renedelima you can rebase now 🎉

Rebased. For now, it seems there are no more suggestions to consider. Let's see what people have to say.

Copy link

@renanbrrenanbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It could also be great to have unit tests inRequestPayloadValueResolverTest.

renedelima reacted with thumbs up emoji
@renedelimarenedelimaforce-pushed themap-uploaded-file branch 2 times, most recently from6312aee to0a29c3aCompareApril 20, 2023 17:32
@renedelimarenedelimaforce-pushed themap-uploaded-file branch 4 times, most recently from9e64462 todc068fbCompareApril 6, 2024 23:27
@nicolas-grekas
Copy link
Member

Anyone @symfony/mergers?
(small rebase needed BTW)

Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice!

@OskarStark
Copy link
Contributor

It looks like your commiter email is not associated with your GitHub account, maybe you want to change that?

renedelima reacted with heart emoji

@renedelimarenedelimaforce-pushed themap-uploaded-file branch 4 times, most recently frome96d7ee toe3f43a0CompareApril 12, 2024 14:48
@OskarStarkOskarStark changed the title[HttpKernel] Introduce MapUploadedFile controller argument attribute[HttpKernel] Introduce#[MapUploadedFile] controller argument attributeApr 13, 2024
Signed-off-by: Rene Lima <renedelima@gmail.com>
@chalasr
Copy link
Member

1 year later. Thanks for your work and your endurance@renedelima!

yceruto, renedelima, GromNaN, and D3lph1 reacted with hooray emojismnandre reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@GromNaNGromNaNGromNaN approved these changes

@ycerutoycerutoyceruto approved these changes

@chalasrchalasrchalasr approved these changes

@dunglasdunglasAwaiting requested review from dunglas

+1 more reviewer

@renanbrrenanbrrenanbr left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

9 participants

@renedelima@carsonbot@Koc@nicolas-grekas@OskarStark@chalasr@renanbr@GromNaN@yceruto

[8]ページ先頭

©2009-2025 Movatter.jp