Friday, 24 July 2020

How to parse an url that links to a zip file with zlib?

Hello,I have translations on the website lokalize, and a function that download them. In my response, I have the url of a zip file, that contains the json. So far so good.I need to extract the json from here, and then output it to a specific path. In order to do that, I use node's zlib.Here is my script:const updateTranslations = async (url, path) => { try { const response = await fetch(url) pipeline( fs.createReadStream(response.url), zlib.createGzip(), fs.createWriteStream(path) ); } catch (error) { throw new Error(error.message); } }; The error is:Error: ENOENT: no such file or directory, open 'https://s3-eu-west-1.amazonaws.com/lokalise-assets/files/export/blablabla.zip'The url is here, and when. I copy/paste it in my browser, the file downloads correctly. But zlib can't parse it, so the script crashes. How to fix this? Should I use another library? If so, which one?Thanks!

Submitted July 24, 2020 at 09:46AM by MonsieurLeland

No comments:

Post a Comment