]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/ImageController.php
Merge branch 'master' into draw.io to fetch auth image changes
[bookstack] / app / Http / Controllers / ImageController.php
index 81e300a68c9950c6060860620bfe9179a04087de..c44b6e480429ab5f24292c0bc8bbab6c631fb789 100644 (file)
@@ -1,6 +1,7 @@
 <?php namespace BookStack\Http\Controllers;
 
 use BookStack\Exceptions\ImageUploadException;
+use BookStack\Exceptions\NotFoundException;
 use BookStack\Repos\EntityRepo;
 use BookStack\Repos\ImageRepo;
 use Illuminate\Filesystem\Filesystem as File;
@@ -28,6 +29,21 @@ class ImageController extends Controller
         parent::__construct();
     }
 
+    /**
+     * Provide an image file from storage.
+     * @param string $path
+     * @return mixed
+     */
+    public function showImage(string $path)
+    {
+        $path = storage_path('uploads/images/' . $path);
+        if (!file_exists($path)) {
+            abort(404);
+        }
+
+        return response()->file($path);
+    }
+
     /**
      * Get all images for a specific type, Paginated
      * @param string $type