mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Integration API: Allow client download
This commit is contained in:
parent
03497e2b71
commit
d73b5e2b82
@ -232,6 +232,11 @@
|
||||
if (!config.events.onSave) { return void cb(); }
|
||||
config.events.onSave(data, cb);
|
||||
});
|
||||
chan.on('GET_BLOB', (data, cb) => {
|
||||
getBlob((err, blob) => {
|
||||
cb({error: err, blob});
|
||||
});
|
||||
});
|
||||
chan.on('RELOAD', function () {
|
||||
config.document.blob = blob;
|
||||
if (!config.editorConfig) { // Not OnlyOffice shim
|
||||
|
||||
@ -161,6 +161,12 @@ define([
|
||||
let getInstanceURL = function () {
|
||||
return Config.httpUnsafeOrigin;
|
||||
};
|
||||
let getBlobClient = (cb) => {
|
||||
chan.send('GET_BLOB', obj => {
|
||||
if (obj?.error) { console.error(obj?.error); }
|
||||
cb(obj?.blob);
|
||||
});
|
||||
};
|
||||
let getBlobServer = function (documentURL, cb) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
let data = encodeURIComponent(documentURL);
|
||||
@ -174,11 +180,11 @@ define([
|
||||
// myBlob is now the blob that the object URL pointed to.
|
||||
cb(null, blob);
|
||||
} else {
|
||||
cb(this.status);
|
||||
getBlobClient(cb);
|
||||
}
|
||||
};
|
||||
xhr.onerror = function (e) {
|
||||
cb(e.message);
|
||||
xhr.onerror = function () {
|
||||
getBlobClient(cb);
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user