[英]phantomjs: Save a base64 string as a file(png)
是的我在Nodejs中做過,但我不能在PhantomJS中。
imgContent = '...base64...string';
imgContent = imgContent.replace(/^data:image\/png;base64,/, "");
chart_path = "/charts.png";
fs.write(chart_path, new Buffer(imgContent, 'base64'), 'w');
錯誤消息:
ReferenceError:找不到變量:Buffer
我不確定它是最好的解決方案,但它對我來說很好。
// ...
fs.write(chart_path, atob(imgContent), 'b');
Phantomjs版本2.1.1。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.