Got: Zip file download works with curl, but not with got...?

Created on 30 Oct 2015  路  3Comments  路  Source: sindresorhus/got

I'm downloading a repo's zip file like so:

var fs = require("fs");
var got = require("got");

got("https://codeload.github.com/sindresorhus/got/zip/master")
.then(res => {
  fs.writeFileSync("master.zip", res.body);
}).catch(err => {
  console.error(err);
});

It produces a master.zip archive that is seemingly corrupt and not openable. :disappointed:

But it works via curl:

$ curl 'https://codeload.github.com/sindresorhus/got/zip/master' -o master.zip 

Any ideas?

Most helpful comment

Pass encoding: null in options to get raw Buffer from got.

All 3 comments

Pass encoding: null in options to get raw Buffer from got.

Thanks. :smile:

Is this still the case? This says Don't set this option to null

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quocnguyen picture quocnguyen  路  4Comments

framerate picture framerate  路  4Comments

f-mer picture f-mer  路  4Comments

alvis picture alvis  路  3Comments

lukechu10 picture lukechu10  路  3Comments