Class: HCAAttachmentUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick, SetAWSConfig, UploaderVirusScan
Defined in:
app/uploaders/hca_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) ⇒ 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_allowlistObject



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

#filenameObject



37
38
39
# File 'app/uploaders/hca_attachment_uploader.rb', line 37

def filename
  @guid
end

#size_rangeObject



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

def size_range
  1.byte...10.megabytes
end

#store_dirObject



33
34
35
# File 'app/uploaders/hca_attachment_uploader.rb', line 33

def store_dir
  'hca_attachments'
end