Class: Pageflow::UploadFileToS3Job

Inherits:
ApplicationJob show all
Includes:
StateMachineJob
Defined in:
app/jobs/pageflow/upload_file_to_s3_job.rb

Instance Method Summary collapse

Instance Method Details

#perform_with_result(file, _options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/jobs/pageflow/upload_file_to_s3_job.rb', line 7

def perform_with_result(file, _options = {})
  if file && file.attachment_on_filesystem.file?
    if File.exist?(file.attachment_on_filesystem.path)
      file.attachment_on_s3 = file.attachment_on_filesystem
      file.save!

      file.attachment_on_filesystem.destroy
      :ok
    else
      logger.info "#{file.class.name} #{file.id} not yet transfered to instance."
      :pending
    end
  else
    logger.warn "#{file.class.name} #{file.id} does not have an attachment on the file system. ignoring."
    :error
  end
end