为什么这样转出来的不对呢。
const opts = {
url: 'http://www.coolaf.com/static/img/s.png'
}
var [err, response] = yield request.get(opts)
var base64 = Buffer.from(response.bod, 'binary').toString('base64')
之前答案就在眼前竟然没点开。。。汗 解决方法
回复 (11)
D
你可以参考下模块node-base64-image的做法
D
引用 DevinXian你可以参考下模块node base64 image的做法
@DevinXian 转出来都是一样的啊
Z
body 是 stream 还是 buffer 还是 string?
PS: 你是怎么判断不对的?
D
引用 zbinlinbody 是 stream 还是 buffer 还是 string? PS: 你是怎么判断不对的?
@zbinlin 用在线base64转图片
Z
哪个网站?
D
引用 dlyt@zbinlin 用在线base64转图片
@dlyt http://coolaf.com/tool/imgtob 类型是String
Z
引用 dlyt@dlyt http://coolaf.com/tool/imgtob 类型是String
@dlyt string 类型使用 Buffer.from(response.body, "binary").toString("base64") 试下
D
引用 zbinlin@dlyt string 类型使用 Buffer.from(response.body, "binary").toString("base64") 试下
@zbinlin 试过了不好用,很像但是差点
Z
你给出来那张图片 http://www.coolaf.com/static/img/s.png 有一个 301 跳转到 http://coolaf.com/static/img/s.png,你是否处理了?
D
M
response.body 为什么是 string?不应该是 buffer吗
参与回复
登录后即可参与回复。登录