lib/carrierwave/storage/s3.rb in locomotive_carrierwave-0.5.0.1.beta3 vs lib/carrierwave/storage/s3.rb in locomotive_carrierwave-0.5.0.1

- old
+ new

@@ -36,15 +36,15 @@ # browser with no authentication. # [:public_read_write] The anonymous principal is granted READ and WRITE access. # [:authenticated_read] Any principal authenticated as a registered Amazon S3 user # is granted READ access. # - # You can change the generated url to a cnamed domain by setting the cname config: + # You can change the generated url to a cnamed domain by setting the cnamed config: # # CarrierWave.configure do |config| - # config.s3_cname = 'bucketname.domain.tld' - # config.s3_bucket = 'bucketname' # only used when storing / deleting files + # config.s3_cnamed = true + # config.s3_bucket = 'bucketname.domain.tld' # end # # Now the resulting url will be # # http://bucketname.domain.tld/path/to/file @@ -120,11 +120,11 @@ end end def public_url if cnamed? - ["http://#{cname}", path].compact.join('/') + ["http://#{bucket}", path].compact.join('/') else ["http://#{bucket}.s3.amazonaws.com", path].compact.join('/') end end @@ -135,11 +135,11 @@ def store(file) content_type ||= file.content_type # this might cause problems if content type changes between read and upload (unlikely) connection.put_object(bucket, path, file.read, { 'x-amz-acl' => access_policy.to_s.gsub('_', '-'), - 'Content-Type' => content_type, + 'Content-Type' => content_type }.merge(@uploader.s3_headers) ) end def content_type @@ -163,16 +163,12 @@ end end private - def cname - @uploader.s3_cname - end - def cnamed? - !@uploader.s3_cname.nil? + @uploader.s3_cnamed end def access_policy @uploader.s3_access_policy end @@ -243,7 +239,5 @@ end end # S3 end # Storage end # CarrierWave - -# module CarrierWave; module Storage; class S3 < Abstract; def connection; @connection ||= Fog::AWS::Storage.new(:aws_access_key_id => uploader.s3_access_key_id, :aws_secret_access_key => uploader.s3_secret_access_key, :host => uploader.s3_cnamed ? uploader.s3_bucket : nil); end; end; end; end