Class: Lcms::Engine::Download
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Lcms::Engine::Download
- Defined in:
- app/models/lcms/engine/download.rb
Constant Summary collapse
- CONTENT_TYPES =
{ zip: 'application/zip', pdf: 'application/pdf', excel: %w(application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), powerpoint: %w(application/vnd.ms-powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation), # rubocop:disable Layout/LineLength doc: %w(application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document) }.freeze
- S3_URL =
'http://k12-content.s3-website-us-east-1.amazonaws.com/'
- URL_PUBLIC_PREFIX =
'public://'
Instance Method Summary collapse
Instance Method Details
#attachment_content_type ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/lcms/engine/download.rb', line 37 def type = content_type CONTENT_TYPES.each do |key, types| if Array.wrap(types).include?(content_type) type = key break end end type end |
#attachment_url ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/models/lcms/engine/download.rb', line 25 def if url.present? url.sub(URL_PUBLIC_PREFIX, S3_URL) else file.url end end |
#s3_filename ⇒ Object
33 34 35 |
# File 'app/models/lcms/engine/download.rb', line 33 def s3_filename File.basename() end |