I would like to create file uploading app to box storage. I use box-sdk module to upload box. The box-sdk can access a file stream that is came from fs.createReadStream for uploading. I use multer module to access uploaded file. The multer module has memorystorage to store files. It produces a buffer string.
For uploading box, I have to convert buffer string to file stream. How can I convert it?
You can just create a readable-stream and push your buffer into it.
var stream = require('stream')
var bufStream = stream.Readable()
bufStream._read = function () {}
bufStream.push(myBuffer)
bufStream.push(null)
bufStream.pause()
You can then pipe
bufStream
wherever you need to pipe it.
You can also use several , various modules to handle this for you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.