Skip to content

[9.x] Add supportsTemporaryUrl to FilesystemAdapter - #43317

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
Jasonej:add-supports-temporary-url
Jul 20, 2022
Merged

taylorotwell merged 2 commits into
laravel:9.xfrom
Jasonej:add-supports-temporary-url

Conversation

@Jasonej

@Jasonej Jasonej commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

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

taylorotwell commented Jul 20, 2022 •

Copy link
Copy Markdown
Member

Hi! What is this fixing or doing?

@Jasonej

Jasonej commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

Renamed to ProvidesTemporaryUrls btw.

salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
* add supportsTemporaryUrl to FilesystemAdapter

* fix code style
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