Class: Pageflow::UploadFileToS3Job

Inherits:
Object
  • Object
show all
Extended by:
StateMachineJob
Defined in:
app/jobs/pageflow/upload_file_to_s3_job.rb

Class Method Summary collapse

Class 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 self.perform_with_result(file, options = {})
  if file && file.attachment_on_filesystem.file?
    if File.exists?(file.attachment_on_filesystem.path)
      file.attachment_on_s3 = file.attachment_on_filesystem
      file.save!

      file.attachment_on_filesystem.destroy unless file.keep_on_filesystem_after_upload_to_s3?
      :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