我想将HTTP响应的内容流式传输到一个变量。我的目标是通过request()
获取图像,并将其存储在MongoDB中--但图像总是被损坏。
这是我的代码:
request('http://google.com/doodle.png', function (error, response, body) {
image = new Buffer(body, 'binary');
db.images.insert({ filename: 'google.png', imgData: image}, function (err) {
// handle errors etc.
});
})
在这种情况下,使用Buffer/streams的最佳方式是什么?
https://stackoverflow.com/questions/14145533
复制相似问题