Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[document_repository] Uploading file too large not reporting correctly #9158 - fix #9174

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/document_repository/jsx/uploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ class DocUploadForm extends Component {
'error'
);
}
if (resp.status == 400) {
swal.fire('Something went wrong',
JSON.parse(resp.response).message,
'error'
);
}
}
}).catch((error) => {
console.error(error);
Expand Down
14 changes: 6 additions & 8 deletions modules/document_repository/php/files.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,18 @@ class Files extends \NDB_Page
if (!is_array($body)) {
throw new \LorisException("Expected parsed body to be an array");
}

$category = $body['category']; // required
if (!\Utility::valueIsPositiveInteger($category)) {
// $category is a string representation of an ID, and so should be
// at least equal to zero.
return new \LORIS\Http\Response\JSON\BadRequest(self::BAD_CATEGORY);
}

$uploadedFiles = $request->getUploadedFiles()['files'] ?? null;

if (is_null($uploadedFiles)) {
header("HTTP/1.1 413 Too_large");
exit;
}
$category = $body['category']; // required
if (!\Utility::valueIsPositiveInteger(strval($category))) {
// $category is a string representation of an ID, and so should be
// at least equal to zero.
return new \LORIS\Http\Response\JSON\BadRequest(self::BAD_CATEGORY);
}

$uploadedFiles = is_array($uploadedFiles)
? $uploadedFiles : [$uploadedFiles];
Expand Down
Loading