Class: HCAAttachmentUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- HCAAttachmentUploader
- Includes:
- CarrierWave::MiniMagick, SetAWSConfig, UploaderVirusScan
- Defined in:
- app/uploaders/hca_attachment_uploader.rb
Instance Method Summary collapse
- #extension_allowlist ⇒ Object
- #filename ⇒ Object
-
#initialize(guid) ⇒ HCAAttachmentUploader
constructor
A new instance of HCAAttachmentUploader.
- #png?(file) ⇒ Boolean private
- #size_range ⇒ Object
- #store_dir ⇒ Object
Methods included from UploaderVirusScan
Methods included from SetAWSConfig
Constructor Details
#initialize(guid) ⇒ HCAAttachmentUploader
Returns a new instance of HCAAttachmentUploader.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 14 def initialize(guid) super @guid = guid if Rails.env.production? set_aws_config( Settings.hca.s3.aws_access_key_id, Settings.hca.s3.aws_secret_access_key, Settings.hca.s3.region, Settings.hca.s3.bucket ) end end |
Instance Method Details
#extension_allowlist ⇒ Object
28 29 30 31 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 28 def extension_allowlist # accepted by enrollment system: PDF,WORD,JPG,RTF %w[pdf doc docx jpg jpeg rtf png] end |
#filename ⇒ Object
37 38 39 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 37 def filename @guid end |
#png?(file) ⇒ Boolean (private)
43 44 45 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 43 def png?(file) file.content_type == 'image/png' end |
#size_range ⇒ Object
8 9 10 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 8 def size_range 1.byte...10.megabytes end |
#store_dir ⇒ Object
33 34 35 |
# File 'app/uploaders/hca_attachment_uploader.rb', line 33 def store_dir 'hca_attachments' end |