Skip to content

Commit

Permalink
Added buildTemporaryUrlsUsing() docs. (#7542)
Browse files Browse the repository at this point in the history
* Added buildTemporaryUrlsUsing() docs.

* Update filesystem.md

* Update filesystem.md

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
ash-jc-allen and taylorotwell authored Dec 31, 2021
1 parent e02643a commit d079911
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,35 @@ If you need to specify additional [S3 request parameters](https://docs.aws.amazo
]
);

If you need to customize how temporary URLs are created for a specific storage disk, you can use the `buildTemporaryUrlsUsing` method. For example, this can be useful if you have a controller that allows you to download files stored via a disk that doesn't typically support temporary URLs. Usually, this method should be called from the `boot` method of a service provider:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Storage::disk('local')->buildTemporaryUrlsUsing(function ($path, $expiration, $options) {
return URL::temporarySignedRoute(
'files.download',
$expiration,
array_merge($options, ['path' => $path])
);
});
}
}

<a name="url-host-customization"></a>
#### URL Host Customization

Expand Down

0 comments on commit d079911

Please sign in to comment.