lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-1.1.1 vs lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-1.1.2

- old
+ new

@@ -7,13 +7,17 @@ alias_method :filename, :path alias_method :identifier, :filename def initialize(uploader, base, path) - @uploader, @path, @base = uploader, URI.encode(path), base + @uploader, @path, @base = uploader, escape(path), base end + def escape(path) + CGI.escape(path).gsub("%2F", "/") + end + def read object, body = bucket.get(path) @headers = object.headers body end @@ -32,13 +36,13 @@ # params # :thumb - Aliyun OSS Image Processor option, etc: @100w_200h_95q # def url(opts = {}) if bucket.mode == :private - bucket.private_get_url(path, opts) + bucket.private_get_url(path, **opts) else - bucket.path_to_url(path, opts) + bucket.path_to_url(path, **opts) end end def content_type headers[:content_type] @@ -51,10 +55,10 @@ def store(new_file, headers = {}) if new_file.is_a?(self.class) new_file.copy_to(path) else fog_file = new_file.to_file - bucket.put(path, fog_file, headers) + bucket.put(path, fog_file, **headers) fog_file.close if fog_file && !fog_file.closed? end true end