Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM did not release if downloading was cancelled and files are corrupted after complete download using streamZipDataTo #57

Open
RizwanAhmad-dev opened this issue Nov 16, 2023 · 0 comments

Comments

@RizwanAhmad-dev
Copy link

I'm using latest version of AWS-s3-zipper to download complete s3 folder if its get downloaded files were corrupted,
and if user cancel the downloading before completion, if hold RAM and did not release it.

steps -
create simple NodeJs Express server with download api -
hit the /download/{gameId} where game Id is the folder of s3 bucket
it will start the downloading

here is the code -
app.get("/download/:gameId", async (req, res, next) => { try { const { gameId } = req.params; const params = { Bucket: config.bucket.name, Prefix: cloudpokernight/${gameId}`,
};
const command = new ListObjectsV2Command(params);
const data = await s3.send(command);

if (!data || !data.Contents || data.Contents.length === 0) {
  return res.status(404).json({ code: 404, error: 'Folder not found in S3' });
}
res.set("content-type", "application/zip");
res.set("Content-Disposition", `attachment; filename=${gameId}.zip`);
zipper.streamZipDataTo(
  {
    pipe: res,
    folderName: params.Prefix,
    startKey: null,
    recursive: true,
  },
  function (err, result) {
    if (err) console.error(err);
    else {
      console.log(result);
    }
  },
);

} catch (err) {
next(err);
}
});`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant