If you ever wanted to disable the link to a certain resource file after some time, this shot will help you accomplish that quickly.
A temporary access file link is a link to a particular resource file with an expiration time.
In this shot, we are going to be using the temporaryUrl()
method to achieve this.
$url = Storage::temporaryUrl(
'file.jpg', now()->addMinutes(5)
);
$url = Storage::temporaryUrl();
This method accepts two parameters:
DateTime
which specifies when the link should expire.use Illuminate\Support\Facades\Storage;
$url = Storage::temporaryUrl(
'file.jpg', now()->addMinutes(5)
);
// send link to user here
temporaryUrl()
method on the Storage
facade and pass the path to the file as file.jpg
.RELATED TAGS
CONTRIBUTOR
View all Courses