0

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

  • put(<ReadableStream>inStream, <string>filename, <function>callback) - success - Sends a file to the server.

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.

1 Answer 1

3

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(){})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.