代码如下
var fs = require('fs')
var bf = fs.readFileSync('../../images/yun.jpg')
var str = bf.toString()
var cp = new Buffer(str)
console.log(bf);
//
如果把toString、Buffer的encoding设置为base64,结果就正常了
原因大概已找到
stackoverflow
Using the default .toString, this will corrupt the data, because it will try to parse the image's binary data as UTF-8 data.
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号