Module: Decidim::ZipStream::Writer
- Included in:
- DownloadYourDataExporter
- Defined in:
- app/services/decidim/zip_stream/writer.rb
Instance Method Summary collapse
- #add_attachments_to_zip_stream(out, export_attachments) ⇒ Object
- #add_user_data_to_zip_stream(out, user_data) ⇒ Object
Instance Method Details
#add_attachments_to_zip_stream(out, export_attachments) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/decidim/zip_stream/writer.rb', line 19 def (out, ) .each do || next if .last.nil? folder_name = .first.parameterize .last.each do || next unless .attached? blobs = .is_a?(ActiveStorage::Attached::One) ? [.blob] : .blobs blobs.each do |blob| out.put_next_entry("#{folder_name}/#{blob.filename}") blob.open do |f| out << f.read end end end end end |
#add_user_data_to_zip_stream(out, user_data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/decidim/zip_stream/writer.rb', line 6 def add_user_data_to_zip_stream(out, user_data) user_data.each do |element| filename_file = element.last.filename(element.first.parameterize) out.put_next_entry(filename_file) if element.last.read.presence out.write element.last.read else out.write "No data" end end end |