Merge branch 'MDL-81757-404' of https://github.com/paulholden/moodle into MOODLE_404_STABLE
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
||||
define("editor_tiny/uploader",["exports","core_form/events","editor_tiny/options"],(function(_exports,_events,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default=(editor,filePickerType,blob,fileName,progress)=>new Promise(((resolve,reject)=>{var _options$savepath;(0,_events.notifyUploadStarted)(editor.targetElm.id);const xhr=new XMLHttpRequest;xhr.upload.addEventListener("progress",(e=>{progress(e.loaded/e.total*100)})),xhr.addEventListener("load",(()=>{if(403===xhr.status)return void reject({message:"HTTP error: ".concat(xhr.status),remove:!0});if(xhr.status<200||xhr.status>=300)return void reject("HTTP Error: ".concat(xhr.status));const response=JSON.parse(xhr.responseText);if(!response)return void reject("Invalid JSON: ".concat(xhr.responseText));let location;if((0,_events.notifyUploadCompleted)(editor.targetElm.id),response.url?location=response.url:response.event&&"fileexists"===response.event&&response.newfile&&(location=response.newfile.url),location&&"string"==typeof location)return void resolve(location);const errorString=xhr.responseText,cleanedErrorString=errorString.replace(/\\/g,"");let output="";try{output=JSON.parse(cleanedErrorString)}catch(error){output=errorString}reject(output)})),xhr.addEventListener("error",(()=>{reject({message:"Upload failed due to an XHR transport error. Code: ".concat(xhr.status),remove:!0})}));const formData=new FormData,options=(0,_options.getFilePicker)(editor,filePickerType);formData.append("repo_upload_file",blob,fileName),formData.append("itemid",options.itemid),Object.values(options.repositories).some((repository=>"upload"===repository.type&&(formData.append("repo_id",repository.id),!0))),formData.append("env",options.env),formData.append("sesskey",M.cfg.sesskey),formData.append("client_id",options.client_id),formData.append("savepath",null!==(_options$savepath=options.savepath)&&void 0!==_options$savepath?_options$savepath:"/"),formData.append("ctx_id",options.context.id);const acceptedTypes=options.accepted_types;Array.isArray(acceptedTypes)?acceptedTypes.forEach((function(type){formData.append("accepted_types[]",type)})):formData.append("accepted_types[]",acceptedTypes),xhr.open("POST","".concat(M.cfg.wwwroot,"/repository/repository_ajax.php?action=upload"),!0),xhr.send(formData)})),_exports.default}));
|
||||
define("editor_tiny/uploader",["exports","core_form/events","editor_tiny/options"],(function(_exports,_events,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default=(editor,filePickerType,blob,fileName,progress)=>new Promise(((resolve,reject)=>{var _options$savepath;(0,_events.notifyUploadStarted)(editor.targetElm.id);const xhr=new XMLHttpRequest;xhr.upload.addEventListener("progress",(e=>{progress(e.loaded/e.total*100)})),xhr.addEventListener("load",(()=>{if(403===xhr.status)return void reject({message:"HTTP error: ".concat(xhr.status),remove:!0});if(xhr.status<200||xhr.status>=300)return void reject("HTTP Error: ".concat(xhr.status));const response=JSON.parse(xhr.responseText);if(!response)return void reject("Invalid JSON: ".concat(xhr.responseText));let location;if((0,_events.notifyUploadCompleted)(editor.targetElm.id),response.url?location=response.url:response.event&&"fileexists"===response.event&&response.newfile&&(location=response.newfile.url),location&&"string"==typeof location)return void resolve(location);const errorString=xhr.responseText;let output="";try{output=JSON.parse(errorString)}catch(error){output=errorString}reject(output)})),xhr.addEventListener("error",(()=>{reject({message:"Upload failed due to an XHR transport error. Code: ".concat(xhr.status),remove:!0})}));const formData=new FormData,options=(0,_options.getFilePicker)(editor,filePickerType);formData.append("repo_upload_file",blob,fileName),formData.append("itemid",options.itemid),Object.values(options.repositories).some((repository=>"upload"===repository.type&&(formData.append("repo_id",repository.id),!0))),formData.append("env",options.env),formData.append("sesskey",M.cfg.sesskey),formData.append("client_id",options.client_id),formData.append("savepath",null!==(_options$savepath=options.savepath)&&void 0!==_options$savepath?_options$savepath:"/"),formData.append("ctx_id",options.context.id);const acceptedTypes=options.accepted_types;Array.isArray(acceptedTypes)?acceptedTypes.forEach((function(type){formData.append("accepted_types[]",type)})):formData.append("accepted_types[]",acceptedTypes),xhr.open("POST","".concat(M.cfg.wwwroot,"/repository/repository_ajax.php?action=upload"),!0),xhr.send(formData)})),_exports.default}));
|
||||
|
||||
//# sourceMappingURL=uploader.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -76,13 +76,11 @@ export default (editor, filePickerType, blob, fileName, progress) => new Promise
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to parse the error response into a JSON object.
|
||||
const errorString = xhr.responseText;
|
||||
// Remove backslashes and escape characters in the stack trace.
|
||||
const cleanedErrorString = errorString.replace(/\\/g, '');
|
||||
// Try to parse the cleaned string into a JSON object.
|
||||
let output = '';
|
||||
try {
|
||||
output = JSON.parse(cleanedErrorString);
|
||||
output = JSON.parse(errorString);
|
||||
} catch (error) {
|
||||
// If the JSON parsing process returns an error, then it returns the original.
|
||||
output = errorString;
|
||||
|
||||
Reference in New Issue
Block a user