fringd / zipline

A gem that lets you stream a zip file from rails
MIT License
289 stars 68 forks source link

Accept a directory path #63

Closed mecampbellsoup closed 3 years ago

mecampbellsoup commented 4 years ago

This is a feature request/proposal.

Would you be amenable to changing zipline's behavior to facilitate usage like the following:

path = '/mnt/path/to/some/directory/with/lots/of/files'
zipline(path, 'my-big-zipfile.zip')

?

swiknaba commented 3 years ago

That should already work, without too much code. Just on mobile ATM, so no formatting or accurate syntax, but did you try sth like:

files = Dir["/path/to/search/**/*.jpg"] # or any regex you need
zipline(
  files.map { |f| [f, f.split("/").last },
  "archive.zip"
)

Just read through this file, it is not that complex: https://github.com/fringd/zipline/blob/master/lib/zipline/zip_generator.rb#L74

mecampbellsoup commented 3 years ago

Yep, naturally I figured this out after I opened this issue and forgot to update here. Thanks!