]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/ImageController.php
Replace dots with something else on user create and edit screens
[bookstack] / app / Http / Controllers / ImageController.php
index 277c27069127856b393a3631a7d9270d0ddf43d5..4d6f759b336eddb97e0516c6ddb69eb8034c9639 100644 (file)
@@ -1,13 +1,12 @@
 <?php namespace BookStack\Http\Controllers;
 
+use BookStack\Entities\Repos\EntityRepo;
 use BookStack\Exceptions\ImageUploadException;
-use BookStack\Exceptions\NotFoundException;
-use BookStack\Repos\EntityRepo;
-use BookStack\Repos\ImageRepo;
+use BookStack\Repos\PageRepo;
+use BookStack\Uploads\Image;
+use BookStack\Uploads\ImageRepo;
 use Illuminate\Filesystem\Filesystem as File;
 use Illuminate\Http\Request;
-use BookStack\Image;
-use BookStack\Repos\PageRepo;
 
 class ImageController extends Controller
 {
@@ -120,7 +119,7 @@ class ImageController extends Controller
     {
         $this->checkPermission('image-create-all');
         $this->validate($request, [
-            'file' => 'is_image'
+            'file' => 'image_extension|no_double_extension|mimes:jpeg,png,gif,bmp,webp,tiff'
         ]);
 
         if (!$this->imageRepo->isValidType($type)) {
@@ -136,7 +135,6 @@ class ImageController extends Controller
             return response($e->getMessage(), 500);
         }
 
-
         return response()->json($image);
     }
 
@@ -164,32 +162,6 @@ class ImageController extends Controller
         return response()->json($image);
     }
 
-    /**
-     * Replace the data content of a drawing.
-     * @param string $id
-     * @param Request $request
-     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
-     */
-    public function replaceDrawing(string $id, Request $request)
-    {
-        $this->validate($request, [
-            'image' => 'required|string'
-        ]);
-        $this->checkPermission('image-create-all');
-
-        $imageBase64Data = $request->get('image');
-        $image = $this->imageRepo->getById($id);
-        $this->checkOwnablePermission('image-update', $image);
-
-        try {
-            $image = $this->imageRepo->replaceDrawingContent($image, $imageBase64Data);
-        } catch (ImageUploadException $e) {
-            return response($e->getMessage(), 500);
-        }
-
-        return response()->json($image);
-    }
-
     /**
      * Get the content of an image based64 encoded.
      * @param $id
@@ -246,7 +218,7 @@ class ImageController extends Controller
 
     /**
      * Show the usage of an image on pages.
-     * @param EntityRepo $entityRepo
+     * @param \BookStack\Entities\Repos\EntityRepo $entityRepo
      * @param $id
      * @return \Illuminate\Http\JsonResponse
      */
@@ -261,6 +233,7 @@ class ImageController extends Controller
      * Deletes an image and all thumbnail/image files
      * @param int $id
      * @return \Illuminate\Http\JsonResponse
+     * @throws \Exception
      */
     public function destroy($id)
     {