Brett
Brett

Reputation: 6020

Nodejs - create a readable stream from an object

How can I create a readable stream from an in-memory object in javascript / nodejs?

I am using 2 libraries - pdfkit and ftp. PDFKit produces a PDF object, which I want to upload from the node app to a remote FTP server.

https://github.com/mscdex/node-ftp

there's lot of resources on how to create readable streams from files, but is it possible to create a readable stream from an in-memory object without using the fs, or would I have to create my own wrapper with emitters? I am not sure on the approach to this.

Upvotes: 0

Views: 929

Answers (1)

Brett
Brett

Reputation: 6020

mscdex has updated the ftp client, so that it can also accept a buffer instead of a stream.

connection.put(new Buffer(object, 'binary'), fName, function(){})

Upvotes: 3

Related Questions