Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def download_zip(image_list)
- unless image_list.blank?
- file_name = 'pictures.zip'
- stringio = Zip::ZipOutputStream::write_buffer do |z|
- z.put_next_entry("empty_folder/") ## Create a folder
- image_list.each do |img|
- title = img.title
- title += '.jpg' unless title.end_with?('.jpg')
- z.put_next_entry(title)
- z.print IO.read(img.path)
- end
- end
- send_data stringio.string, :type => 'application/zip', :disposition => 'attachment', :filename => file_name
- end
- end
Add Comment
Please, Sign In to add comment