Skip to content
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

[9.x] Add supportsTemporaryUrl to FilesystemAdapter #43317

Merged
merged 2 commits into from
Jul 20, 2022

Conversation

Jasonej
Copy link
Contributor

@Jasonej Jasonej commented Jul 20, 2022

This PR adds a supportsTemporaryUrl() method to FilesystemAdapter that checks if the adapter has getTemporaryUrl or a temporaryUrlCallback.

@Jasonej Jasonej marked this pull request as draft July 20, 2022 14:18
@Jasonej Jasonej marked this pull request as ready for review July 20, 2022 14:48
@taylorotwell
Copy link
Member

taylorotwell commented Jul 20, 2022

Hi! What is this fixing or doing?

@Jasonej
Copy link
Contributor Author

Jasonej commented Jul 20, 2022

Hi, it's seeking to allow the following in situations where temp urls are preferred when supported, but are not required.

$filesystem = Storage::disk($disk);

$url = $filesystem->supportsTemporaryUrl()
    ? $filesystem->temporaryUrl($path, $expiration)
    : $filesystem->url($path);

Currently, the temporaryUrlCallback is not exposed as it is protected, so to accomplish this behavior the options are to assume that no callback exists and rely on a method_exists() check or do a try/catch that checks for the RuntimeException that is thrown by temporaryUrl().

@taylorotwell taylorotwell merged commit ff0dc5b into laravel:9.x Jul 20, 2022
@Jasonej Jasonej deleted the add-supports-temporary-url branch July 20, 2022 18:54
@driesvints
Copy link
Member

Renamed to ProvidesTemporaryUrls btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants