我们的应用程序是由ionic framework angular file saver插件开发的,该插件在所有浏览器中都运行良好,但在构建windows桌面应用程序后无法运行,我想将文件保存在下载目录中,而blob文件需要保存。
downloadDocument(document_uuid,fileName){
let req={
"order_uuid":this.order_uuid,
"document_uuid":document_uuid
};
this.documentLoader=true;
this.documentData="d-none";
this.userService.DownloadDocument(req).subscribe((data:any)=>{
console.log(data);
this.documentLoader=false;
this.documentData="";
if(data.statusCode==200){
var downloadBase64=data['data']['documentDataBase64'];
console.log("base 64 conversion",downloadBase64);
var contentType = "";
var type=(fileName).split('.');
var fileType=type[1];
switch(fileType){
case "xls":
contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
break;
case "xlsx":
contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
break;
case "doc":
contentType="application/msword";
break;
case "docx":
contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document";
break;
case "odt":
contentType="application/vnd.oasis.opendocument.text";
break;
case "txt":
contentType="text/plain";
break;
case "zip":
contentType="application/zip";
break;
case "rtf":
contentType="application/rtf";
break;
case "rar":
contentType="application/vnd.rar";
break;
case "pdf":
contentType="application/pdf";
break;
case "csv":
contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
break;
case "jpeg":
contentType="image/jpeg";
break;
case "png":
contentType="image/png";
break;
case "gif":
contentType="image/gif";
break;
}
const byteArray = new Uint8Array(atob(downloadBase64).split('').map(char => char.charCodeAt(0)));
let blob = new Blob([byteArray], {type:contentType});
const url = window.URL.createObjectURL(blob);
let filename = data['data']['file_name'];
FileSaver.saveAs(blob,filename);
}
})
}
但在生成windows桌面应用程序后未保存文件。
暂无答案!
目前还没有任何答案,快来回答吧!