How to use private local storage with ImageEntry
How do I setup private local storage so I can store images that are not publicly accessible and load them via ImageEntry? I tried specifying the
I also tried using
->disk('private')
but its not working.
Do I need to create a Controller and if so how should that be used with ImageEntry? I tried like ->url(fn ($record) => route('secure-images.show', ['filename' => $record->image_url]))
but this isn't working for me either.I also tried using
->visibility('private')
but I'm not having any luck wth that either...Solution:Jump to solution
Not really sure, but I think you also need to specify
->visibility('private')
on the ImageEntry?3 Replies
I found a similar question/answer https://discord.com/channels/883083792112300104/1145723690839973908 but it's not working for me.
@CodeWithDennis Do you have any suggestions for what I could be missing here? Thanks The documentation says "The entry must contain the path to the image, relative to the root directory of its storage disk, or an absolute URL to it." and I've stored the images in my providers
@CodeWithDennis Do you have any suggestions for what I could be missing here? Thanks The documentation says "The entry must contain the path to the image, relative to the root directory of its storage disk, or an absolute URL to it." and I've stored the images in my providers
image_url
column with the relative path like provider-images/01HWX.jpg
In my AppServiceProvider.php
I am using buildTemporaryUrlsUsing
as instructed:
In my ViewProvider.php
the ImageEntry->url()
works as expected and I can see the image if I visit that URL directly but the image is still not loading from the image_url
column in my database
EditProvider.php
is correctly storing images in /storage/app/private/provider-images/
web.php
(using ->where('path', '.*')
as @CodeWithDennis suggested.
In the logs I can see the URL is generated as I expect but the image fails to load because it's trying from https://mydomain.com/storage/provider-images/01HWX.jpg
instead of the ->url()
path like https://mydomain.com/private/temp/provider-images/01HWXQR459X1ABFQTHPQV9DACQ.jpg?expires=1714749092&signature=73a61b...
Solution
Not really sure, but I think you also need to specify
->visibility('private')
on the ImageEntry?Thanks, I can't belive that was it >.< I thought that would cause a conflict since I am creating temporary urls already manually.