Integration API: Allow client download

This commit is contained in:
yflory 2025-11-24 15:43:31 +01:00
parent 03497e2b71
commit d73b5e2b82
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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();
};