node-zip icon indicating copy to clipboard operation
node-zip copied to clipboard

zip file obtained cant be opened

Open markl-vesper opened this issue 5 years ago • 4 comments

I'm using node-zip package in AWS Lambda function to serve up a couple of files from S3 bucket to client via API/GW.

API Call via Postman is returning data however when I save that data to a .zip file and try to extract I'm getting told its not a valid zip file.

Below is example of code without all the S3 stuff as its not relevant

const zip = require("node-zip")();

// gets files from S3 OK then zips them up

zip.file(certFilePath, getCRTResponse);

zip.file(privateKeyPath, getPrivateKeyResponse);

const data = zip.generate({ base64: false, compression: "DEFLATE" });

responseBody = {
    statusCode: 200,
    headers: {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET, POST",
        "Content-type": "application/zip",
        "Content-Disposition": "attachment; filename='" + certPath[3] + "-" + event.pathParameters.serial + ".zip'"
    },
    body: data
};

callback(null, responseBody);

markl-vesper avatar Feb 26 '19 23:02 markl-vesper