0

How to store the data into a file for a jpeg that has been fetched successfully in nodejs ?

12th Aug 2022, 1:23 PM
Abhay
Abhay - avatar
8 odpowiedzi
+ 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.
12th Aug 2022, 1:51 PM
Abhay
Abhay - avatar
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.
12th Aug 2022, 2:09 PM
Abhay
Abhay - avatar
0
<DD> not interested in doing that but thks.
12th Aug 2022, 2:25 PM
Abhay
Abhay - avatar