Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sajadsholi's avatar

does temporaryUrl function in laravel request to aws to get temporary url for private files every times?

I use the AWS S3 filesystem to get/upload ... files in Laravel and I have an accessor like this that gets the file URL and passes it to the front end. everything is fine and I can see/upload my files

    public function getFileAttribute()
    {
        if ($this->disk == 's3') {
            return Storage::disk($this->disk)->temporaryUrl($this->full_path_with_client_name, now()->addMinutes(60));
        }

        return url('/') . str_replace(config('app.url'), '', Storage::disk($this->disk)->url($this->full_path_with_client_name));
    }

I want to show a lot of images in a page so I fetch my media data from db and make the URL based on path and name and pass it to the front

my question is every time I show images(fetch media) the Laravel request to AWS or check the URL expired to decide to make a request or not

if everytime laravel make a request I want to make a command like refreshTepmrorayUrlCommand to get and store URL in db and refresh the URL after URL expired

0 likes
0 replies

Please or to participate in this conversation.