lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-0.8.1 vs lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-0.9.0
- old
+ new
@@ -8,13 +8,13 @@
@path = URI.encode(path)
@base = base
end
def read
- object = bucket.get(@path)
- @headers = object.headers
- object
+ res = bucket.get(@path)
+ @headers = res.headers.deep_transform_keys { |k| k.underscore.to_sym rescue key }
+ res.body
end
def delete
bucket.delete(@path)
true
@@ -36,25 +36,25 @@
bucket.path_to_url(@path, opts)
end
end
def content_type
- headers[:content_type]
+ headers[:content_type].first
end
def content_type=(new_content_type)
headers[:content_type] = new_content_type
end
def store(file, headers = {})
bucket.put(@path, file, headers)
end
- private
-
def headers
@headers ||= {}
end
+
+ private
def bucket
return @bucket if defined? @bucket
@bucket = CarrierWave::Aliyun::Bucket.new(@uploader)