0
How to store the data into a file for a jpeg that has been fetched successfully in nodejs ?
8 Antworten
+ 2
<DD> ty for your response, Don't know what data it is . But i am using fetch to get the image ,now i want to store whatever image data(in bytes or any other format) fetch function send us, in a jpeg file .
Fyi , it is not about sending to a client or anyone else . I could download the file through browser but just want to see how it can be done using node js.
0
<DD> my code is a mess ,anyway i tried writing something by following this link and going through other articles ,but didn't understand how to do it.
https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeTo
The above article explains how to use "pipeto" to direct readableStream to writeableStream but i am unable to create writeableStream .
Though ,I coded a simple writestream but it didn't work out .
let writeStream = fs.createWriteStream("something.jpeg"
);
Error : TypeError [ERR_INVALID_ARG_TYPE]: The "transform.writable" property must be an instance of WritableStream. Received an instance of WriteStream.
0
<DD> not interested in doing that but thks.