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

Zip file is empty (0 bytes) #100

Open
joaoreynolds opened this issue May 19, 2024 · 1 comment
Open

Zip file is empty (0 bytes) #100

joaoreynolds opened this issue May 19, 2024 · 1 comment

Comments

@joaoreynolds
Copy link

joaoreynolds commented May 19, 2024

Suddenly I'm unable to get s3-zip to produce a valid zip file. This started happening this week without any updates to my code base or node versions.

Environment:

  • Node 20.13.1
  • Express JS: "4.16.1" (probably not relevant)
  • @aws-sdk/client-s3: "3.521.0"

Code:

const filePaths = files.map(myFile => myFile.path)

console.log('creating a zip from: ')
console.log(filePaths) // just an array of file paths in s3

const archiverEntryData = files.map(myFile => ({
  name: `${myFile.type}/${myFile.originalName}` // "type" isn't filetype, it's more like what area the file came from in our app
}))

s3Zip
.archive({ region: 'us-east-2', bucket: config.s3Bucket, debug: true }, '', filePaths, archiverEntryData)
.pipe(res)

Output

creating a zip from:
[
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/rk0lGYi2a1709048309719.jpeg',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/rJx0gGKj261709048309721.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/ry-AxGKj361709048309722.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/BJzClfFs3T1709048309723.png',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/Hyb8zKs3a1709048393227.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/rykHmKj2a1709048630694.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/SkqwQYsnT1709048673598.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/B1doXYonT1709048736347.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/Bkr0XFi2a1709048780690.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/ryozNKi2a1709048850607.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/H1u8VYih61709048911527.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/By5F4Yo361709048961920.pdf',
  'org-5927a1e253ea6534838869a1/perm-65de01f5f18dd0498b296394/BJLjEYjna1709048990265.pdf'
]
append to zip { name: 'form/Test Document 1.pdf' }
append to zip { name: 'form/Test Document 4.pdf' }
append to zip { name: 'form/Test Document 4-1.pdf' }
append to zip { name: 'internal_comments/Test Document 2.pdf' }
append to zip { name: 'messages/Test Document 3.pdf' }
append to zip { name: 'messages/Test Document 1.pdf' }
append to zip {
  name: 'plan-reviews/Business Plans/submission-1/submitted/Test Document 1.pdf'
}
append to zip { name: 'messages/Test Document 3-1.pdf' }
append to zip {
  name: 'plan-reviews/Business Plans/submission-1/review-Police/Site Plans - Reviewed.pdf'
}
append to zip {
  name: 'plan-reviews/Business Plans/submission-1/response/Test Document 4.pdf'
}
append to zip {
  name: 'plan-reviews/Business Plans/submission-2/submitted/Test Document 2.pdf'
}
append to zip { name: 'form/IMG_7681-edit.jpg' }
append to zip { name: 'form/Screenshot 2024-02-27 at 8.37.40 AM.png' }
end -> finalize

Produces a zip file with zero bytes. Used to work just fine. Hoping somebody has noticed this happening suddenly as well. I wonder if something changed about the output stream from AWS?

I even tried copying your source code and then outputting from the progress event with archiver, and it says zero bytes processed.

Thanks in advance for any help. I’ve been banging my head against the wall for about 20 hours now.

@joaoreynolds
Copy link
Author

Oh wow, this problem existed earlier I just didn't have any users report it earlier. Looks like a few weeks ago I introduced a package that imported buffer, which my best guess is causing problems. Hopefully this helps someone in the future 🤞

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