Sha256: 09f5a4c10d56d1715c745e5fb3a1aa0e23ab4dfd388b0bd8941fe0d6507bd8e1

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Cms
  module Attachments
    
    # Automatically used to serve files when the following configuration is set:
    #   config.cms.attachments.storage = :s3
    class S3Strategy
      
      # Redirects users to the file on S3.
      #   Issues:
      #     1. No security, all files are assumed to be public
      #     2. CNAMEs are not supported.
      def self.send_attachment(attachment, controller)
        controller.redirect_to attachment.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
      
      # For S3, this returns the relative path within the bucket.
      # I.e. http://s3.amazonaws.com/:bucket/:attachments_storage_location/:path_to_file
      def self.attachments_storage_location
        "/attachments"
      end
            
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
bcms_aws_s3-artirix-4.0.1 lib/cms/attachments/s3_strategy.rb
bcms_aws_s3-artirix-4.0.0.rc1.art4 lib/cms/attachments/s3_strategy.rb
bcms_aws_s3-1.0.2 lib/cms/attachments/s3_strategy.rb
bcms_aws_s3-1.0.1 lib/cms/attachments/s3_strategy.rb
bcms_awss3-1.0.0 lib/cms/attachments/s3_strategy.rb