Class: Cms::Attachments::S3Strategy
- Inherits:
-
Object
- Object
- Cms::Attachments::S3Strategy
- Defined in:
- lib/cms/attachments/s3_strategy.rb
Overview
Automatically used to serve files when the following configuration is set:
config.cms..storage = :s3
Class Method Summary collapse
-
.attachments_storage_location ⇒ Object
For S3, this returns the relative path within the bucket.
-
.send_attachment(attachment, controller) ⇒ Object
Redirects users to the file on S3.
Class Method Details
.attachments_storage_location ⇒ Object
For S3, this returns the relative path within the bucket. I.e. s3.amazonaws.com/:bucket/:attachments_storage_location/:path_to_file
25 26 27 |
# File 'lib/cms/attachments/s3_strategy.rb', line 25 def self. "/attachments" end |
.send_attachment(attachment, controller) ⇒ Object
Redirects users to the file on S3.
Issues:
1. No security, all files are assumed to be public
2. CNAMEs are not supported.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cms/attachments/s3_strategy.rb', line 12 def self.(, controller) controller.redirect_to .url # Possible s3_cname implementation # if Cms::S3.options[:s3_cname] # redirect_to("http://#{Cms::S3.options[:s3_cname]}/#{@attachment.file_location}") # else # redirect_to("http://#{Cms::S3.options[:bucket]}.s3.amazonaws.com/#{@attachment.file_location}") # end end |