Skip to content

zip file obtained cant be opened #32

@markl-vesper

Description

@markl-vesper

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions