Hello,
I have an export feature in my add-on that saves user data into a file.
However it seems to work only in Windows and not in Ubuntu (the Save file dialog won’t be shown instead the page with text data will be opened).
Is there a way to make saving files working on all platforms? Also I don’t want to use Download API for this as it would require a new permission.
Currently I have two distinct methods for this and both of them has the same issue:
function downloadFile(filename, textData) {
const node = buildElement('a', {href: `data:text/plain;charset=utf-8,${encodeURIComponent(textData)}`, download: filename, style: 'display: none'});
document.body.appendChild(node);
node.click();
document.body.removeChild(node);
}
function createDownloadFileLink(aNode, fileName, extension, data) {
aNode.download = `${fileName}.${extension}`;
aNode.href = URL.createObjectURL(new Blob([JSON.stringify(data)], {type : 'application/json'}));
aNode.dataset.downloadurl = `${extension}:${aNode.download}:${aNode.href}`;
}