diff --git a/src/locales/en.json b/src/locales/en.json index 7d64b01f0..46563d226 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -143,5 +143,6 @@ "pad.impexp.uploadFailed": "The upload failed, please try again", "pad.impexp.importfailed": "Import failed", "pad.impexp.copypaste": "Please copy paste", - "pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details." + "pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details.", + "pad.impexp.maxFileSize": "File too big. Contact your site administrator to increase the allowed file size for import" } diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index e3bdcb1c6..e62cb9417 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -82,6 +82,12 @@ async function doImport(req, res, padId) if (err) { console.warn("Uploading Error: " + err.stack); } + + // I hate doing indexOf here but I can't see anything to use... + if (err.stack.indexOf("maxFileSize") !== -1) { + reject("maxFileSize"); + } + reject("uploadFailed"); } if(!files.file){ // might not be a graceful fix but it works @@ -261,7 +267,7 @@ exports.doImport = function (req, res, padId) let status = "ok"; doImport(req, res, padId).catch(err => { // check for known errors and replace the status - if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData") { + if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData" || err == "maxFileSize") { status = err; } else { throw err; diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js index 70220f87e..001c4f83d 100644 --- a/src/static/js/pad_impexp.js +++ b/src/static/js/pad_impexp.js @@ -111,6 +111,8 @@ var padimpexp = (function() msg = html10n.get("pad.impexp.uploadFailed"); } else if(status === "padHasData"){ msg = html10n.get("pad.impexp.padHasData"); + } else if(status === "maxFileSize"){ + msg = html10n.get("pad.impexp.maxFileSize"); } function showError(fade)