Monday 21 October 2019

Downloading a zip archive from Express endpoint

Hello, everyoneI have a simple issue, but it's been driving me crazy for the past 2 days. I have an archive.zipfile in my node/express app which I'm trying to send via a response. My code is pretty simple, I have an endpoint /download whos only job is to do response.download("archive.zip")However, upon downloading the file (by accessing the URL through a browser), the .zip archive is downloaded, but the files in the archive are corrupted, and I get the error Unexpected end of archive.The actual file is a good, non-corrupted archive. I can access it on the windows filesystem without any problems. It's just when it gets transferred it gets corrupted.I have tried setting various response headers, among which:Content-Disposition: attachment Content-Type: application/zip, application/content-stream Transfer-Encoding: chunked Nothing has worked up to this point. I have searched far and wide on google / reddit / stackoverflow and haven't come up with a solution so far.Thank you for any or all responses.

Submitted October 21, 2019 at 01:12PM by remus2232

No comments:

Post a Comment