The Amazon S3 Access policy ready to send in storage request headers.
# File lib/carrierwave/storage/s3.rb, line 127 def access_policy return @access_policy unless @access_policy.blank? if @uploader.s3_access_policy.blank? if !@uploader.s3_access.blank? @access_policy = @uploader.s3_access.to_s.gsub(/_/, '-') else @access_policy = 'public-read' end else @access_policy = @uploader.s3_access_policy end end
# File lib/carrierwave/storage/s3.rb, line 140 def content_type headers["content-type"] end
# File lib/carrierwave/storage/s3.rb, line 144 def content_type=(type) headers["content-type"] = type end
Remove the file from Amazon S3
# File lib/carrierwave/storage/s3.rb, line 97 def delete connection.delete(bucket, @path) end
Headers returned from file retrieval
# File lib/carrierwave/storage/s3.rb, line 149 def headers @headers ||= {} end
# File lib/carrierwave/storage/s3.rb, line 116 def store(file) content_type ||= file.content_type # this might cause problems if content type changes between read and upload (unlikely) connection.put(bucket, @path, file.read, { 'x-amz-acl' => access_policy, 'content-type' => content_type }.merge(@uploader.s3_headers) ) end
# File lib/carrierwave/storage/s3.rb, line 64 def initialize(uploader, base, path) @uploader = uploader @path = path @base = base end