Class: PreneedAttachmentUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- PreneedAttachmentUploader
- Includes:
- CarrierWave::MiniMagick, SetAWSConfig, UploaderVirusScan
- Defined in:
- app/uploaders/preneed_attachment_uploader.rb
Instance Method Summary collapse
- #extension_allowlist ⇒ Object
- #filename ⇒ Object
-
#initialize(guid) ⇒ PreneedAttachmentUploader
constructor
A new instance of PreneedAttachmentUploader.
- #not_pdf?(file) ⇒ Boolean private
- #size_range ⇒ Object
- #store_dir ⇒ Object
Methods included from UploaderVirusScan
Methods included from SetAWSConfig
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_allowlist ⇒ Object
28 29 30 |
# File 'app/uploaders/preneed_attachment_uploader.rb', line 28 def extension_allowlist %w[pdf jpg jpeg png] end |
#filename ⇒ Object
38 39 40 |
# File 'app/uploaders/preneed_attachment_uploader.rb', line 38 def filename "#{super.chomp(File.extname(super))}.pdf" end |
#not_pdf?(file) ⇒ Boolean (private)
44 45 46 |
# File 'app/uploaders/preneed_attachment_uploader.rb', line 44 def not_pdf?(file) file.content_type != 'application/pdf' end |
#size_range ⇒ Object
8 9 10 |
# File 'app/uploaders/preneed_attachment_uploader.rb', line 8 def size_range 1.byte...25.megabytes end |
#store_dir ⇒ Object
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 |