如何将图像写入具有缓冲区的服务器?

How to write an image to a server having a Buffer?

我在 Expressjs 中上传了一张图片。它作为一个 Buffer 编码 7bit:

 { fieldname: 'file',
  originalname: 'img.JPG',
  encoding: '7bit',
  mimetype: 'image/jpeg',
  buffer: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 64 00 64 00 00 ff db 00 43 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 0
1 01 01 01 01 01 ... >,
  size: 873066 }

如何将其保存为图片到文件系统?保存了一些东西,但它不是图像:

Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted of too large.

这些不起作用:

fs.writeFile('uploaded-img.jpg', req.file, 'ascii', function(err) {

fs.writeFile('uploaded-img.jpg', req.file.toString('ascii'), 'ascii', function(err) {

怎么样:

fs.writeFile('uploaded-img.jpg', req.file.buffer, 'ascii', function(err) {