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

Can't use ReadableStream from generateNodeStream in the PutObjectCommand of s3 #918

Open
palashCItobuz opened this issue Feb 1, 2024 · 0 comments

Comments

@palashCItobuz
Copy link

I was trying to create a zip and upload it to the s3 bucket using v3 sdk.

          const zip = new JSZip(); 
          fileArr.forEach((file: string) => {
            zip.folder("./")?.file(file, fs.readFileSync(path.join(reportDir, file)));
          });
          const content: NodeJS.ReadableStream = zip.generateNodeStream({
            type: "nodebuffer",
            streamFiles: true
          });
          
          try {
              const uploadCommand = new PutObjectCommand({
                  Bucket: config.S3_REPORT_DOWNLOAD_BUCKET,
                  Key: zipFile,
                  Body: content
              });
              data = await s3ClientUpload.send(uploadCommand);
              console.log("ZIP file uploaded to S3");
          } catch (error) {
              console.log(error);
          }

Here we are using content in the Body parameter of PutObjectCommand but it fails to recognize the readstream.

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