lib/paperclip-aws.rb in paperclip-aws-1.6.7 vs lib/paperclip-aws.rb in paperclip-aws-1.6.8
- old
+ new
@@ -45,17 +45,17 @@
if options[:expires].present? || options[:action].present?
options.reverse_merge!({
:expires => 60*60,
:action => :read
})
- secure = ( self.choose_protocol(style, options) == 'https' )
+ secure = ( self.choose_protocol(style, options) == 'https:' )
return self.s3.buckets[@s3_bucket].objects[path(style).gsub(%r{^/}, "")].url_for(options[:action], { :secure => secure, :expires => options[:expires] }).to_s
else
if @s3_host_alias.present?
- url = "#{choose_protocol(style, options)}://#{@s3_host_alias}/#{path(style).gsub(%r{^/}, "")}"
+ url = "#{choose_protocol(style, options)}//#{@s3_host_alias}/#{path(style).gsub(%r{^/}, "")}"
else
- url = "#{choose_protocol(style, options)}://#{@s3_endpoint}/#{@s3_bucket}/#{path(style).gsub(%r{^/}, "")}"
+ url = "#{choose_protocol(style, options)}//#{@s3_endpoint}/#{@s3_bucket}/#{path(style).gsub(%r{^/}, "")}"
end
return URI.escape(url)
end
end
@@ -90,14 +90,16 @@
return false
end
end
def choose_protocol(style, options={})
- if options[:protocol].present?
- return options[:protocol].to_s
+ protocol = if options[:protocol].present?
+ options[:protocol].to_s
else
- return @s3_protocol.is_a?(Proc) ? @s3_protocol.call(style, self) : @s3_protocol
+ @s3_protocol.is_a?(Proc) ? @s3_protocol.call(style, self) : @s3_protocol
end
+
+ "#{protocol}:" if protocol.present?
end
# Returns representation of the data of the file assigned to the given
# style, in the format most representative of the current storage.
def to_file(style = default_style)