Completed user quota implementation
This commit is contained in:
parent
17c24860b2
commit
038fb156c1
4 changed files with 5 additions and 9 deletions
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Database\DB;
|
||||
use App\Database\Migrator;
|
||||
use App\Web\Media;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use League\Flysystem\Filesystem;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use App\Web\View;
|
|||
use DI\Container;
|
||||
use DI\DependencyException;
|
||||
use DI\NotFoundException;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use League\Flysystem\Filesystem;
|
||||
use Monolog\Logger;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use League\Flysystem\FileExistsException;
|
||||
use Exception;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
|
@ -62,7 +62,7 @@ class UploadController extends Controller
|
|||
|
||||
$file = array_values($request->getUploadedFiles());
|
||||
/** @var \Psr\Http\Message\UploadedFileInterface|null $file */
|
||||
$file = isset($file[0]) ? $file[0] : null;
|
||||
$file = $file[0] ?? null;
|
||||
|
||||
if ($file === null) {
|
||||
$json['message'] = 'Request without file attached.';
|
||||
|
@ -125,13 +125,13 @@ class UploadController extends Controller
|
|||
$published,
|
||||
]);
|
||||
|
||||
$json['message'] = 'OK.';
|
||||
$json['message'] = 'OK';
|
||||
$json['url'] = urlFor("/{$user->user_code}/{$code}.{$fileInfo['extension']}");
|
||||
|
||||
$this->logger->info("User $user->username uploaded new media.", [$this->database->getPdo()->lastInsertId()]);
|
||||
|
||||
return json($response, $json, 201);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->updateUserQuota($request, $user->id, $file->getSize(), true);
|
||||
throw $e;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
// Auth routes
|
||||
use App\Controllers\AdminController;
|
||||
use App\Controllers\Auth\LoginController;
|
||||
use App\Controllers\Auth\PasswordRecoveryController;
|
||||
use App\Controllers\Auth\RegisterController;
|
||||
use App\Controllers\ClientController;
|
||||
use App\Controllers\DashboardController;
|
||||
use App\Controllers\ExportController;
|
||||
use App\Controllers\Auth\LoginController;
|
||||
use App\Controllers\MediaController;
|
||||
use App\Controllers\ProfileController;
|
||||
use App\Controllers\SettingController;
|
||||
|
|
Loading…
Reference in a new issue