Module: Pageflow::EntryExportImport::AttachmentFiles

Extended by:
AttachmentFiles
Included in:
AttachmentFiles
Defined in:
lib/pageflow/entry_export_import/attachment_files.rb

Overview

Download/upload files during export/import

Instance Method Summary collapse

Instance Method Details

#archive_path(reusable_file, attachment, exported_id: reusable_file.id) ⇒ Object



28
29
30
31
32
33
# File 'lib/pageflow/entry_export_import/attachment_files.rb', line 28

def archive_path(reusable_file, attachment, exported_id: reusable_file.id)
  File.join(reusable_file.file_type.collection_name,
            exported_id.to_s,
            attachment.name.to_s,
            attachment.original_filename)
end

#download_and_archive_originals(revision, archive) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/pageflow/entry_export_import/attachment_files.rb', line 7

def download_and_archive_originals(revision, archive)
  revision.file_usages.each do |file_usage|
    reusable_file = file_usage.file

    reusable_file.attachments_for_export.each do |attachment|
      download_and_archive_attachment_file(reusable_file, attachment, archive)
    end
  end
end

#extract_and_upload_originals(entry, archive_file_name, file_mappings) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/pageflow/entry_export_import/attachment_files.rb', line 17

def extract_and_upload_originals(entry, archive_file_name, file_mappings)
  each_reusable_file(entry) do |reusable_file|
    exported_id = file_mappings.exported_id_for(reusable_file.class.name,
                                                reusable_file.id)

    UploadAndPublishFileJob.perform_later(reusable_file,
                                          exported_id,
                                          archive_file_name)
  end
end