I have a profile page where user uploads their driving license image, I'm storing these images in Amazon s3 bucket with private visibility$path = $request->file('image')->store('avatars', 's3')
. I want to display this image in user profile page, As the files are private to access these images i found solution that i have to create temporary URLs to access the image as follows
$image_path = Storage::disk('s3')->temporaryUrl(
'avatars/'.$license->imageName,
Carbon::now()->addMinutes(20)
);
The$image_path
is returning me temporary path of url which I can use in<img src="{{$image_path}}"
tag but issue with this solution is even if I copy and paste this temporary url in incognito mode its returning the image , as 20 minutes time is set , this solution my client is not accepting as image is accessible in private window even though its temporary access.
another solution that i found without generating temporary url is by usingreturn $src = Storage::disk('s3')->response('avatars/'.$image->filename);
if i return this line it will print image in the browser. but i want do display image in the blade file if i print this$src
in the blade file{{src}}
is outputingHTTP/1.0 200 OK Cache-Control: no-cache, private Content-Disposition: inline; filename=vkMv0NcQGBoq3U9C7DUNhzujA6tLEp8dQEIMJCO2.jpg Content-Length: 1630 Content-Type: image/jpeg Date: Wed, 03 Nov 2021 10:07:56 GMT
.
Please guide is there any way i can print these image in blade , or any other way to access private files without generating temporary urls
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.