srjrol
srjrol
FFilament
Created by srjrol on 5/2/2024 in #❓┊help
How to use private local storage with ImageEntry
Thanks, I can't belive that was it >.< I thought that would cause a conflict since I am creating temporary urls already manually.
5 replies
FFilament
Created by srjrol on 5/2/2024 in #❓┊help
How to use private local storage with ImageEntry
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 image_url column with the relative path like provider-images/01HWX.jpg In my AppServiceProvider.php I am using buildTemporaryUrlsUsing as instructed:
public function boot(): void
{
Storage::disk('private')->buildTemporaryUrlsUsing(function ($path, $expiration, $options = []) {
return URL::temporarySignedRoute(
'private.temp',
$expiration,
array_merge($options, ['path' => $path])
);
});
}
public function boot(): void
{
Storage::disk('private')->buildTemporaryUrlsUsing(function ($path, $expiration, $options = []) {
return URL::temporarySignedRoute(
'private.temp',
$expiration,
array_merge($options, ['path' => $path])
);
});
}
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
$imageUrl = Storage::disk('private')->temporaryUrl(
$this->record->image_url,
now()->addMinutes(60)
);

ImageEntry::make('image_url')
->disk('private')
->url($imageUrl)
$imageUrl = Storage::disk('private')->temporaryUrl(
$this->record->image_url,
now()->addMinutes(60)
);

ImageEntry::make('image_url')
->disk('private')
->url($imageUrl)
EditProvider.php is correctly storing images in /storage/app/private/provider-images/ web.php (using ->where('path', '.*') as @CodeWithDennis suggested.
Route::get('private/temp/{path}', [ImageController::class, 'show'])
->where('path', '.*')
->name('private.temp');
Route::get('private/temp/{path}', [ImageController::class, 'show'])
->where('path', '.*')
->name('private.temp');
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...
5 replies