feat: update error codes in the storage API
This commit is contained in:
parent
6a8401dfe5
commit
d9fbe80317
|
@ -239,4 +239,9 @@ return [
|
|||
'description' => 'The uploaded file is invalid. Please check the file and try again.',
|
||||
'statusCode' => 403,
|
||||
],
|
||||
Exception::STORAGE_FAILED_TO_MOVE_FILE => [
|
||||
'name' => Exception::STORAGE_FAILED_TO_MOVE_FILE,
|
||||
'description' => 'Failed to copy the uploaded file.',
|
||||
'statusCode' => 500,
|
||||
],
|
||||
];
|
|
@ -116,7 +116,7 @@ App::post('/v1/storage/files')
|
|||
$path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION));
|
||||
|
||||
if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move'
|
||||
throw new Exception('Failed moving file', 500);
|
||||
throw new Exception('Failed moving file', 500, Exception::STORAGE_FAILED_TO_MOVE_FILE);
|
||||
}
|
||||
|
||||
$mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption
|
||||
|
@ -127,7 +127,7 @@ App::post('/v1/storage/files')
|
|||
|
||||
if (!$antivirus->fileScan($path)) {
|
||||
$device->delete($path);
|
||||
throw new Exception('Invalid file', 403);
|
||||
throw new Exception('Invalid file', 403, Exception::STORAGE_INVALID_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class Exception extends \Exception
|
|||
const STORAGE_INVALID_WRITE_PERMISSIONS = 'storage_invalid_write_permissions';
|
||||
const STORAGE_INVALID_FILE_SIZE = 'storage_invalid_file_size';
|
||||
const STORAGE_INVALID_FILE = 'storage_invalid_file';
|
||||
const STORAGE_FAILED_TO_MOVE_FILE = 'storage_failed_to_move_file';
|
||||
|
||||
/** Projects */
|
||||
const PROJECT_NOT_FOUND = 'project_not_found';
|
||||
|
|
Loading…
Reference in a new issue