mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
parent
98d84125f0
commit
608f7d58c4
@ -10,8 +10,16 @@ const factory = (NaclUtil) => {
|
||||
window.atob = window.atob || function (str) { return Buffer.from(str, 'base64').toString('binary'); };
|
||||
window.btoa = window.btoa || function (str) { return Buffer.from(str, 'binary').toString('base64'); };
|
||||
|
||||
Util.encodeBase64 = NaclUtil.encodeBase64;
|
||||
Util.encodeBase64 = u8 => {
|
||||
if (typeof(u8?.toBase64) === "function") {
|
||||
return u8.toBase64();
|
||||
}
|
||||
return NaclUtil.encodeBase64(u8);
|
||||
}
|
||||
Util.decodeBase64 = str => {
|
||||
if (typeof(Uint8Array?.fromBase64) === "function") {
|
||||
return Uint8Array.fromBase64(str);
|
||||
}
|
||||
let i = str.length % 4;
|
||||
if (i) { str += '='.repeat(4-i); }
|
||||
return NaclUtil.decodeBase64(str);
|
||||
@ -23,18 +31,6 @@ const factory = (NaclUtil) => {
|
||||
return Array.prototype.slice.call(A, start, end);
|
||||
};
|
||||
|
||||
Util.u8ToBase64 = (u8, cb) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
let res = reader.result;
|
||||
let trim = res.slice(res.indexOf(',') + 1);
|
||||
cb(trim);
|
||||
};
|
||||
reader.readAsDataURL(new Blob([u8]));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Util.shuffleArray = function (a) {
|
||||
for (var i = a.length - 1; i > 0; i--) {
|
||||
var j = Math.floor(Math.random() * (i + 1));
|
||||
|
||||
@ -33,7 +33,7 @@ define([
|
||||
|
||||
module.uploadFile = function (common, data, cb) {
|
||||
var sframeChan = common.getSframeChannel();
|
||||
sframeChan.query('Q_UPLOAD_FILE', data, cb);
|
||||
sframeChan.query('Q_UPLOAD_FILE', data, cb, {raw: true});
|
||||
};
|
||||
|
||||
module.create = function (common, config) {
|
||||
@ -220,14 +220,13 @@ define([
|
||||
|
||||
file.noStore = config.noStore;
|
||||
try {
|
||||
Util.u8ToBase64(u8, b64 => {
|
||||
file.blob = b64;
|
||||
file.teamId = teamId;
|
||||
common.uploadFile(file, function () {
|
||||
console.log('Upload started...');
|
||||
});
|
||||
file.blob = u8;
|
||||
file.teamId = teamId;
|
||||
common.uploadFile(file, function () {
|
||||
console.log('Upload started...');
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
UI.alert(Messages.upload_serverError);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1700,7 +1700,6 @@ define([
|
||||
}
|
||||
});
|
||||
};
|
||||
data.blob = Utils.Util.decodeBase64(data.blob);
|
||||
Files.upload(data, data.noStore, Cryptpad, updateProgress, onComplete, onError, onPending);
|
||||
cb();
|
||||
});
|
||||
|
||||
2
www/common/worker.bundle.min.js
vendored
2
www/common/worker.bundle.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user