0
I started in Windows a little while ago, at the moment the files are being stored inside the Storage folder, but I will use the cloud storage library of google cloud, can create and read files normally but the problem is when trying to get the file url to be able to preview the files in the application that will be consuming my Rest api.
This is the file structure:
storage
|- app
| |- data
| |- public
| |- images
| |- produtos
| |- supermercados
|- 1
| - 9d92b1d506a2065c4c0d132dbeb32217016d2a57f67a48ca7373cdff6bcd9ee6.jpeg
df974bf001ec886ab8ace6cdfab5850cf12ae66323927d55ccf591cc2f3079c0.jpeg
|- framework
|- logs
I’m trying to get the link like this:
Storage::url('data/images/supermercados/' . $supermercado->id . '/' . $supermercado->foto);
Where id is the supermarket folder and photo is the name of the photo
But instead of getting a link I get this path:
\/storage\/data\/images\/supermercados\/1\/df974bf001ec886ab8ace6cdfab5850cf12ae66323927d55ccf591cc2f3079c0.jpeg
How do I get a URL like http://site.com/imagem.jpge ?
Just set a route with that name
/imagem.jpge
and on the route written in the controller put something likepublic function imagem() { return Storage::download('data/images/supermercados/' . $supermercado->id . '/' . $supermercado->foto, 'image.jpg', [ 'Content-Type' => 'image/jpeg' ]); }
– Guilherme Nascimento
I had a similar problem yesterday. Take a test. Open the
php artisan tinker
and typeenv('APP_URL')
. If you have returned other than what is in the file.env
, it is very likely that your folderbootstrap/cache
has saved some information empty or different from the current configuration. If I am not mistaken, it can be solved easily withphp artisan cache:clear
.– Wallace Maxters
@Guilhermenascimento I am in doubt, I use a library to load the images called Glide, when passing the url it will perform a download or the library will load it from the server?
– Samuel Ives
You said you were using a cloud, so this would be internal to the very API of the Laravel to solve, now if you did something of your own we have no way of knowing and the doubt is ambiguous. If you can detail it will help us to help you.
– Guilherme Nascimento