I've written the following method inside the controller which goes through all the files in a folder and returns these:
$files = Storage::files($gallery);
public function showGallery($gallery)
{
$gallery = base64_decode($gallery);
$gallery_name = explode('/', $gallery);
$directories = Storage::directories($gallery);
$galleries = $gallery_name;
unset($galleries[0]);
unset($galleries[1]);
array_pop($galleries);
$files = Storage::files($gallery);
$locations = array();
foreach ($files as $file)
{
if($this->is_image($file))
{
$locations[] = Image::make(storage_path('app/' . $file))->encode( 'data-url' );
} else
{
$locations[] = storage_path('app/' . $file);
}
}
//dd($locations);
$data = [
'directories' => $directories,
'galleries' => $galleries,
'gallery_path' => $gallery,
'gallery_name' => end($gallery_name),
'locations' => $locations,
];
return view('private.user.gallery', $data);
}
After this I am separating images from other file types.
I'm using the Intervention Image library to make Images publicly available and viewable.
However I'm stuck when displaying other files (as icons) such as PDF, doc,mov files.
When I click on those icons in the front-end I get this error.
link: http://lamotte.local/home/vagrant/projects/lamotte/storage/app/gallery/Brand/pdf-test.pdf
NotFoundHttpException in RouteCollection.php line 161:
The reason these files are in storage is because these files need to be access-controlled through a login system.
Is there a library that can handle this?