mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-23 07:10:00 +08:00
Improved image upload error handling and fixed bad user-avatar rewriting
This commit is contained in:
6
app/Exceptions/ImageUploadException.php
Normal file
6
app/Exceptions/ImageUploadException.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php namespace BookStack\Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class ImageUploadException extends Exception {}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace BookStack\Http\Controllers;
|
namespace BookStack\Http\Controllers;
|
||||||
|
|
||||||
|
use BookStack\Exceptions\ImageUploadException;
|
||||||
use BookStack\Repos\ImageRepo;
|
use BookStack\Repos\ImageRepo;
|
||||||
use Illuminate\Filesystem\Filesystem as File;
|
use Illuminate\Filesystem\Filesystem as File;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -69,7 +70,13 @@ class ImageController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$imageUpload = $request->file('file');
|
$imageUpload = $request->file('file');
|
||||||
|
|
||||||
|
try {
|
||||||
$image = $this->imageRepo->saveNew($imageUpload, $type);
|
$image = $this->imageRepo->saveNew($imageUpload, $type);
|
||||||
|
} catch (ImageUploadException $e) {
|
||||||
|
return response($e->getMessage(), 500);
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json($image);
|
return response()->json($image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ module.exports = function (ngApp) {
|
|||||||
var usingIds = typeof scope.currentId !== 'undefined' || scope.currentId === 'false';
|
var usingIds = typeof scope.currentId !== 'undefined' || scope.currentId === 'false';
|
||||||
scope.image = scope.currentImage;
|
scope.image = scope.currentImage;
|
||||||
scope.value = scope.currentImage || '';
|
scope.value = scope.currentImage || '';
|
||||||
|
if (usingIds) scope.value = scope.currentId;
|
||||||
|
|
||||||
function setImage(imageModel, imageUrl) {
|
function setImage(imageModel, imageUrl) {
|
||||||
scope.image = imageUrl;
|
scope.image = imageUrl;
|
||||||
|
Reference in New Issue
Block a user