Sha256: a8b498a7198cc71559f3bbb527ffdece84b585611da45acd7c1fdc8fc3012c3e
Contents?: true
Size: 936 Bytes
Versions: 18
Compression:
Stored size: 936 Bytes
Contents
# frozen_string_literal: true module Decidim class DownloadYourDataExportJob < ApplicationJob queue_as :default def perform(user, export_format = ::Decidim::DownloadYourDataExporter::DEFAULT_EXPORT_FORMAT) filename = "#{SecureRandom.urlsafe_base64}.zip" path = Rails.root.join("tmp/#{filename}") password = SecureRandom.urlsafe_base64 generate_zip_file(user, path, password, export_format) save_or_upload_file(user, path) # Deletes temporary file File.delete(path) ExportMailer.download_your_data_export(user, filename, password).deliver_later end private def generate_zip_file(user, path, password, export_format) DownloadYourDataExporter.new(user, path, password, export_format).export end def save_or_upload_file(user, path) user.download_your_data_file.attach(io: File.open(path, "rb"), filename: File.basename(path)) end end end
Version data entries
18 entries across 18 versions & 1 rubygems