Handle 413 responses from Nginx when uploading files too large

Fixes #5171
This commit is contained in:
Frédéric Guillot
2023-04-14 20:11:51 -07:00
committed by Frédéric Guillot
parent 0b1c2011ed
commit bd50288030
3 changed files with 17 additions and 4 deletions

View File

@@ -25,6 +25,12 @@ KB.component('file-upload', function (containerElement, options) {
KB.trigger('modal.stop');
}
function onRequestTooLarge() {
var label = options.labelOversize ? options.labelOversize : options.labelUploadError;
var errorElement = KB.dom('div').addClass('file-error').text(label).build();
KB.find('#file-item-' + currentFileIndex).add(errorElement);
}
function onComplete() {
currentFileIndex++;
@@ -92,7 +98,7 @@ KB.component('file-upload', function (containerElement, options) {
function uploadFiles() {
if (files.length > 0) {
KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError);
KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError, onRequestTooLarge);
}
}