'What kind of encoding is this and how to convert it into readable stream in nodejs to save?
Solution 1:[1]
Solved it using node-fetch and on response.body() it's returning a readable stream.
Solution 2:[2]
Based on the presence of EXIF and XMP data, you're looking at an image.
You can't process it as a (human-readable-text) string, so there is no "encoding" to work with. Just store it as binary.
Solution 3:[3]
This might not be what you want, but I believe it answers the second part of your question:
It could be different depending on which HTTP client you are using, but if you use the node http or https module, then the response will be a readable stream by default.
import https from "https";
const req = https.request(
"https://example.com",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
},
(res) => {
/* res extends <stream.Readable> */
}
);
const postData = JSON.stringify({ msg: "hello world" });
req.write(postData);
req.end();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | AKX |
| Solution 3 |

