-
-
Notifications
You must be signed in to change notification settings - Fork 87
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(manage): allow users to upload game icon images #2682
feat(manage): allow users to upload game icon images #2682
Conversation
->image() | ||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/gif']) | ||
->maxSize(1024) | ||
->rules('dimensions:width=96,height=96') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are "uploaded" files stored? Do they automatically get cleaned up? I attached a wrongly sized file and it still appears to have been uploaded:
Also, the error message remains after uploading a different (correctly sized) image.
And uploading that generated an error:
What permission do I need?
If the user doesn't have permission, should the field even be there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Draft" files (for lack of a better term) are uploaded to storage/app/temp. Filament only tries to associate them with the game when the user clicks the form submit button.
They are indeed automatically cleaned up (see ProcessUploadedImageAction::cleanUpTempFiles()
), but it's a side effect. Maybe it would make sense for the cleanup code to run on some kind of schedule?
The permission needed is GamePolicy::update()
.
Visibility is indeed conditional based on this policy in GameResource.php on line 347.
Authorization passes if the user has any role of GAME_HASH_MANAGER, DEVELOPER_STAFF, DEVELOPER, or DEVELOPER_JUNIOR.
The authorization call occurs in GameResource/Pages/Edit.php
on line 20.
My user account has the DEVELOPER
role. This is what I see when I use the control locally:
Brave.Browser.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Draft" files (for lack of a better term) are uploaded to storage/app/temp.
It seems like it maintains the filename of the uploaded file. If two users both upload a "icon.png" at roughly the same time, will one overwrite the other?
Wrongly sized files don't appear in that folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still getting the error. And I have at least two of the roles you've identified.
2024-09-08.08-27-40.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to attack this in a separate branch using a different approach. I think Filament's built-in file upload component enforces a few assumptions that may not make sense for how we want to handle uploading and storing these assets right now. I'd like to try again with a simple native file input from within Filament. However, Filament doesn't support this out of the box, so I'll need to build the component by hand. |
This PR makes a change to allow developers to upload new game icon images via the management app's game edit page.
Other media types will be supported in the future, but this felt like a good chunk to knock out first just to establish a pattern that can be applied to those other fields.
Brave.Browser.mp4