简体   繁体   English

如何在 Angular 中将 base64 转换为文档文件 txt 格式

[英]How to Convert base64 to Document File txt Format in Angular

I have return data base64 string.我有返回数据库 base64 字符串。 How to view this base64 data in txt file ?如何在 txt 文件中查看这个 base64 数据?

base64 Text: 'data:text/plain;base64,=' base64 文本:'数据:文本/纯文本;base64,='

If you want to decode the value you can do a split and then use atob .如果要解码值,可以进行拆分,然后使用atob Something like this像这样的东西

 const data = '...'
 const text = atob(data.split(",")[1]);

Note: this will return the content of the file and not the file itself.注意:这将返回文件的内容,而不是文件本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM