rabiloo/laravel-local-temporary-url

This package provides temporary url method for local filesystem driver

v1.1.1 2025-01-07 03:43 UTC

This package is auto-updated.

Last update: 2025-03-07 04:09:53 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Provides temporaryUrl() method for local filesystem driver

Laravel Local Temporary Url

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.

Installation

You can install the package via composer:

composer require rabiloo/laravel-local-temporary-url

Usage

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));

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.