根据文件对象下载文件

const doDownload = (item) => {
    let aUrl = item.address;
    let extNameIcon = item.extName;
    let extName = item.name;
    if (extName.includes(".")) {
        extName = extName.split(".")[0];
    }
    let xml = new XMLHttpRequest();
    xml.open("GET", aUrl, true);
    xml.responseType = "blob";
    xml.onload = () => {
        let url = window.URL.createObjectURL(xml.response);
        let a = document.createElement("a");
        a.href = url;
        a.download = `${extName}.${extNameIcon}`;
        a.style.display = "none";
        a.click();
    };
    xml.send();
};
posted @ 2023-06-25 09:43  Felix_Openmind  阅读(20)  评论(0)    收藏  举报
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}