"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Creating Temporary URLs for Local Files in Laravel

Creating Temporary URLs for Local Files in Laravel

Published on 2024-11-08
Browse:398

Creating Temporary URLs for Local Files in Laravel

Working with private files in Laravel usually means involving third-party services like S3 or DigitalOcean. But what if you’re in a local development environment or have a lightweight project? You might not want to depend on third-party cloud services.

Luckily, Laravel makes it easy to serve temporary URLs for files stored locally. This approach can speed up development and simplify file sharing.

You just need to change the FILESYSTEM_DISK to local from your .env file.

FILESYSTEM_DISK=local

Next, check your config/filesystems.php file. Under the 'local' disk configuration, set 'serve' => true, if it's not there you can add it.

Once your configuration is set, you can use Laravel's Storage::temporaryUrl() to create URLs that expire after a defined time, keeping your files secure.

Here's a more detailed version of this article to help you understand better if you could catch on: https://laraveleco.com/laravel-how-to-create-temporary-url-for-files-in-local-disk/


If you liked this article and want to support, you can do so by buying me a coffee.

Release Statement This article is reproduced at: https://dev.to/kachkolasa/creating-temporary-urls-for-local-files-in-laravel-15o9?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3