Class: PreneedAttachmentUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick, SetAWSConfig, UploaderVirusScan
Defined in:
app/uploaders/preneed_attachment_uploader.rb

Instance Method Summary collapse

Methods included from UploaderVirusScan

#validate_virus_free

Methods included from SetAWSConfig

#set_aws_config

Constructor Details

#initialize(guid) ⇒ PreneedAttachmentUploader

Returns a new instance of PreneedAttachmentUploader.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/uploaders/preneed_attachment_uploader.rb', line 14

def initialize(guid)
  super
  @guid = guid

  if Rails.env.production?
    set_aws_config(
      Settings.preneeds.s3.aws_access_key_id,
      Settings.preneeds.s3.aws_secret_access_key,
      Settings.preneeds.s3.region,
      Settings.preneeds.s3.bucket
    )
  end
end

Instance Method Details

#extension_allowlistObject



28
29
30
# File 'app/uploaders/preneed_attachment_uploader.rb', line 28

def extension_allowlist
  %w[pdf jpg jpeg png]
end

#filenameObject



38
39
40
# File 'app/uploaders/preneed_attachment_uploader.rb', line 38

def filename
  "#{super.chomp(File.extname(super))}.pdf" if original_filename.present?
end

#size_rangeObject



8
9
10
# File 'app/uploaders/preneed_attachment_uploader.rb', line 8

def size_range
  1.byte...25.megabytes
end

#store_dirObject



32
33
34
35
36
# File 'app/uploaders/preneed_attachment_uploader.rb', line 32

def store_dir
  raise 'missing guid' if @guid.blank?

  "preneed_attachments/#{@guid}"
end