const sessionData: any = sessionStorage.getItem("token");
const tokenHead: any = sessionStorage.getItem("headerType");
let params = {
fileInfoId: row.fileInfoId,
id: row.id,
name: row.name,
};
axios({
method: "post",
url: apiConstatns.URL.META_BASE.FILE_DOWNDILE,
data: params,
responseType: "blob",
headers: { Authorization: tokenHead + sessionData },
}).then((res: any) => {
let blob = new Blob([res.data], { type: "application/octet-stream" });
const downloadElement = document.createElement("a");
const headers = res.headers;
const fileName = filterDate(row.createTime) + row.name;
downloadElement.download = fileName;
downloadElement.href = URL.createObjectURL(blob);
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
});
前端文件流、切片下载和上传
2024-05-15 15:42:07 34 阅读