Provides temporaryUrl()
method for local filesystem driver
NOTE: Laravel 11 comes with native support for this feature. See https://laravel.com/docs/11.x/filesystem#temporary-urls This package provides the same feature for Laravel 9+ versions.
You can install the package via composer:
composer require rabiloo/laravel-local-temporary-url
Enable by config (See https://laravel.com/docs/11.x/filesystem#enabling-local-temporary-urls )
# config/filesystems.php
return [
'disks' => [
//
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'serve' => true, // Enable file server, default URL is `/local/temp/{path}?expires=xxx&signature=xxx`
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public', // Enable file server with `visibility` = `public`
'throw' => false,
],
// Custom local disk
'local2' => [
'driver' => 'local',
'root' => storage_path('app/local2'),
'throw' => false,
'serve' => true, // Enable file server
'url' => 'local2/tmp', // The URL will be `/local2/tmp/{path}?expires=xxx&signature=xxx`
],
//...
],
];
Make temporary URL
use Illuminate\Support\Facades\Storage;
$url = Storage::disk('local')->temporaryUrl($path, now()->addSeconds(120));
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.