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

Breaks piping binary data to browser #72

Open
hallvors opened this issue Aug 31, 2022 · 0 comments
Open

Breaks piping binary data to browser #72

hallvors opened this issue Aug 31, 2022 · 0 comments

Comments

@hallvors
Copy link

I tried to add swagger-express-validator to a code base and found that an API returning PDFs fetched from Google cloud storage started returning 0 bytes. This was a surprise and it took me a while to realise adding swagger-express-validator was the cause. The code is quite simple, lots of examples recommend this pattern:

    const gcsBucket = gcs.bucket(bucketName);

    result = await gcsBucket
      .file(gcsFilePath)
      .createReadStream()
      .on("error", function (err) {
        console.log("Error downloadFileFromGcs");
        console.log(err);
        throw new ApiError(404, 'Not found');
      })
      .on("end", function () {
        // The file is fully downloaded.
        console.log("downloadFileFromGcs: The file is fully downloaded.");
      })
      .pipe(res);
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