We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On my node server and try to download a png image from a url and write it to a file:
request .get("https://url/for/png/file") .on('error', function(err) { console.log(err) }) .on('response', function(response){ console.log(response.statusCode) // 200 console.log(response.headers['content-type']); // 'image/png' }) .on('complete', (resp: http.IncomingMessage, body: string | Buffer) => { fs.writeFile(".../test.png", body, 'binary'); });
The main issue is that the written file is corrupted (can't be opened).
If I use pipe instead of on('complete'...) at the end the written file is correct.
.pipe(fs.createWriteStream(".../test.png"))
What exactly is the difference and what am I missing to be able to write the file?
The text was updated successfully, but these errors were encountered:
The same problem.
Sorry, something went wrong.
use encoding: null option
@lambdacerro Thank you, will close this issue then.
No branches or pull requests
On my node server and try to download a png image from a url and write it to a file:
The main issue is that the written file is corrupted (can't be opened).
If I use pipe instead of on('complete'...) at the end the written file is correct.
What exactly is the difference and what am I missing to be able to write the file?
The text was updated successfully, but these errors were encountered: