Merge pull request #20604 from nextcloud/backport/20595/stable16
[stable16] Fix IE11 upload fallback methods
This commit is contained in:
commit
10b7463468
|
@ -44,6 +44,28 @@ OC.FileUpload = function(uploader, data) {
|
|||
OC.FileUpload.CONFLICT_MODE_DETECT = 0;
|
||||
OC.FileUpload.CONFLICT_MODE_OVERWRITE = 1;
|
||||
OC.FileUpload.CONFLICT_MODE_AUTORENAME = 2;
|
||||
|
||||
// IE11 polyfill
|
||||
// TODO: nuke out of orbit as well as this legacy code
|
||||
if (!FileReader.prototype.readAsBinaryString) {
|
||||
FileReader.prototype.readAsBinaryString = function(fileData) {
|
||||
var binary = ''
|
||||
var pt = this
|
||||
var reader = new FileReader()
|
||||
reader.onload = function (e) {
|
||||
var bytes = new Uint8Array(reader.result)
|
||||
var length = bytes.byteLength
|
||||
for (var i = 0; i < length; i++) {
|
||||
binary += String.fromCharCode(bytes[i])
|
||||
}
|
||||
// pt.result - readonly so assign binary
|
||||
pt.content = binary
|
||||
$(pt).trigger('onload')
|
||||
}
|
||||
reader.readAsArrayBuffer(fileData)
|
||||
}
|
||||
}
|
||||
|
||||
OC.FileUpload.prototype = {
|
||||
|
||||
/**
|
||||
|
@ -943,7 +965,8 @@ OC.Uploader.prototype = _.extend({
|
|||
try {
|
||||
var reader = new FileReader();
|
||||
reader.readAsBinaryString(file);
|
||||
} catch (NS_ERROR_FILE_ACCESS_DENIED) {
|
||||
} catch (error) {
|
||||
console.log(reader, error)
|
||||
//file is a directory
|
||||
dirUploadFailure = true;
|
||||
}
|
||||
|
@ -1059,6 +1082,7 @@ OC.Uploader.prototype = _.extend({
|
|||
message = response.message;
|
||||
}
|
||||
}
|
||||
console.error(e, data, response)
|
||||
OC.Notification.show(message || data.errorThrown, {type: 'error'});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue