DEV Community

Kachkol Asa
Kachkol Asa

Posted on • Originally published at laraveleco.com

2

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
Enter fullscreen mode Exit fullscreen mode

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.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs