i currently develop a chrome extension. This extension create a blob and let the user download the "file" blob.
My problem is when i create the file, it's on some site it's open correctly, and other website it's open in a new tab
There is my code, i think i did not make mistake
function downloadBlob(blob){
var FileName = "test.txt";
var urlCreator = window.URL || window.webkitURL;
var Link = urlCreator.createObjectURL(blob, { type: "application/octet-stream" });
var a = window.document.createElement("a");
a.href = Link;
a.download = FileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
Did the CSP of the website, could impact my blob download ?
I also try to return the link, set it to a new link. Always the same result. When i return the link, if i "right click" and press save as, my file is save successfully.
I also see there is a chrome.downloads.dowload
can i use it in my extension ? I try it, but did not work.
https://developer.chrome.com/extensions/downloads