Last active
October 21, 2022 21:24
-
-
Save snelson82/b37bb823a9268eb7258ac85b95999bef to your computer and use it in GitHub Desktop.
Compressing a folder using RubyZip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zip' | |
archive_directory_path = '' | |
archive_zip_path = '' | |
Zip::File.open(archive_zip_path, Zip::File::CREATE) do |zip_file| | |
Dir[File.join(archive_directory_path, "**", "**")].each do |file| | |
zip_file.add(file.sub("#{ archive_directory_path}/", ""), file) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The original thread is found here: https://gist.github.com/yoon/8876313?permalink_comment_id=3578082#gistcomment-3578082