search

Home  >  Q&A  >  body text

node.js - [求助]nodejs中如何将一个文件转为Blob binary data

现在我已经把文件读成byte[]不知道下一步怎么做了?

黄舟黄舟2905 days ago629

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-17 14:40:17

    The following function reads the file. After Node.js reads the file, data is saved in binary Buffer format. The data in Blob format is also saved in binary mode, so it can be said that data This is what the questioner wanted Blob binary data. I don’t know if it solves the questioner’s problem.

    var fs = require('fs')
    fs.readFile('/etc/passwd', function (err, data) {
      if (err) throw err
      console.log('isBuffer: ' + Buffer.isBuffer(data)) // isBuffer: true
      console.log(data) // <Buffer 72 6f ... >
    })

    reply
    0
  • Cancelreply