Feat: Add custom openable/downloadable URLs support for file uploads#19481
Open
Abdulmajeed-Jamaan wants to merge 6 commits intofilamentphp:4.xfrom
Open
Feat: Add custom openable/downloadable URLs support for file uploads#19481Abdulmajeed-Jamaan wants to merge 6 commits intofilamentphp:4.xfrom
Abdulmajeed-Jamaan wants to merge 6 commits intofilamentphp:4.xfrom
Conversation
Include server-provided openable URLs in uploaded file metadata and use them for the file open action. JS: add uploadedFile.metadata to the file options and prefer metadata.openableUrl (falling back to file.source) when generating the open link. PHP: introduce a getOpenableUrlUsing closure property and setter, and populate metadata.openableUrl for each stored file by evaluating the callback. This enables customizable/signed URLs or alternate domains for opening uploaded files.
Support custom downloadable URLs for uploaded files. Backend: add a getDownloadableUrlUsing callback and property on BaseFileUpload, populate metadata.downloadableUrl when isDownloadable() and the callback is set, and ensure openable URL generation checks isOpenable(). Frontend: prefer metadata.downloadableUrl for the download anchor href (fallback to file.source behavior removed). This enables serving custom download links separate from the file source.
…jeed-Jamaan/filament into feat/custom-openable-url
Remove an extra blank line and standardize conditional formatting in BaseFileUpload: add consistent spacing and braces for the openable/downloadable URL checks and tidy up the getDownloadableUrlUsing method. Purely stylistic changes with no functional impact.
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.
Description
Spatie Media Library provides image generators that create derived image files from media (e.g., generating thumbnails from uploaded PDFs). However, the current FileUpload component does not support using different URLs for the preview image and the open/download button.
Introduce server-provided openable/downloadable URLs in uploaded file metadata and use them for the file open action by utilizing FilePond Metadata object.
This enables customizable/signed URLs or alternate domains for opening/downloading uploaded files.
Visual changes
None
Functional changes
JS: add uploadedFile.metadata to the file options and prefer metadata.openableUrl (falling back to file.source) when generating the open link, the same for downloadable.
PHP: introduce a getOpenableUrlUsing closure property and setter, and populate metadata.openableUrl for each stored file by evaluating the callback, the same for downloadable.
composer cscommand.