Nova-Filemanager
Nova-Filemanager copied to clipboard
Non-public images breaks preview
If my bucket has non-public images, I'd like to generate signed URLs for previews, to avoid 403s on the frontend. Any suggestions on where to extend the library to get that behaviour? Thanks.
// src/Http/Services/NormalizeFile.php
/**
* Returns the image or the svg icon preview.
*
* @return mixed
*/
private function getImage($mime, $extension = false)
{
if (Str::contains($mime, 'image') || $extension == 'svg') {
return $this->storage->url($this->storagePath);
}
$fileType = new FileTypesImages();
return $fileType->getImage($mime);
}
Same issue here) @fedeisas did you solve it?
hi, all, I was investigating the flysystem api, and to be able to have the files non-public in s3, we need to create presigned requests. This can be done using
$this->storage->temporaryUrl($path, '+5 minutes');
With this we can display the image in the preview.
I think this should be done using a configuration to request this kind of temporary urls
This is the patch I'm using for now:
+++ ../src/Http/Services/NormalizeFile.php
@@ -50,7 +50,7 @@
'mime' => $this->getCorrectMimeFileType(),
'path' => $this->storagePath,
'size' => $this->getFileSize(),
- 'url' => $this->cleanSlashes($this->storage->url($this->storagePath)),
+ 'url' => $this->cleanSlashes($this->storage->temporaryUrl($this->storagePath, '+5 minutes')),
'date' => $this->modificationDate(),
'ext' => $this->file->getExtension(),
]);
@@ -145,7 +145,7 @@
private function getImage($mime, $extension = false)
{
if (Str::contains($mime, 'image') || $extension == 'svg') {
- return $this->storage->url($this->storagePath);
+ return $this->storage->temporaryUrl($this->storagePath, '+5 minutes');
}
$fileType = new FileTypesImages();