lib/httpimagestore/configuration/s3.rb in httpimagestore-1.8.0 vs lib/httpimagestore/configuration/s3.rb in httpimagestore-1.8.1
- old
+ new
@@ -1,8 +1,9 @@
require 'aws-sdk'
require 'digest/sha2'
require 'msgpack'
+require 'addressable/uri'
require 'httpimagestore/aws_sdk_regions_hack'
require 'httpimagestore/configuration/path'
require 'httpimagestore/configuration/handler'
require 'httpimagestore/configuration/source_failover'
@@ -175,11 +176,11 @@
def write(data, options = {})
s3_object.write(data, options)
end
def private_url
- s3_object.url_for(:read, expires: 60 * 60 * 24 * 365 * 20) # expire in 20 years
+ s3_object.url_for(:read, expires: 60 * 60 * 24 * 365 * 20)
end
def public_url
s3_object.public_url
end
@@ -235,23 +236,23 @@
@cache_file.header['content_type'] = options[:content_type] if options[:content_type]
dirty! :write
end
def private_url
- url = @cache_file.header['private_url'] and return URI(url)
+ url = @cache_file.header['private_url'] and return Addressable::URI.parse(url)
dirty! :private_url
url = super
@cache_file.header['private_url'] = url.to_s
- url
+ Addressable::URI.parse(url)
end
def public_url
- url = @cache_file.header['public_url'] and return URI(url)
+ url = @cache_file.header['public_url'] and return Addressable::URI.parse(url)
dirty! :public_url
url = super
@cache_file.header['public_url'] = url.to_s
- url
+ Addressable::URI.parse(url)
end
def content_type
@cache_file.header['content_type'] ||= (dirty! :content_type; super)
end
@@ -312,13 +313,12 @@
cache_root
)
end
def initialize(global, image_name, matcher, bucket, path_spec, public_access, cache_control, prefix, cache_root)
- super global, image_name, matcher
+ super global, image_name, matcher, path_spec
@bucket = bucket
- @path_spec = path_spec
@public_access = public_access
@cache_control = cache_control
@prefix = prefix
@cache_root = nil
@@ -331,11 +331,11 @@
end
rescue CacheRoot::CacheRootNotDirError => error
log.warn "not using S3 object cache for image '#{image_name}'", error
end
- local :bucket, @bucket
+ config_local :bucket, @bucket
end
def client
@global.s3 or raise S3NotConfiguredError
end
@@ -404,10 +404,10 @@
end
end
end
def to_s
- "S3Source[image_name: '#{@image_name}' bucket: '#{@bucket}' prefix: '#{@prefix}' path_spec: '#{@path_spec}']"
+ "S3Source[image_name: '#{image_name}' bucket: '#{@bucket}' prefix: '#{@prefix}' path_spec: '#{path_spec}']"
end
end
Handler::register_node_parser S3Source
SourceFailover::register_node_parser S3Source