lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-1.2.0 vs lib/carrierwave/storage/aliyun_file.rb in carrierwave-aliyun-1.2.1
- old
+ new
@@ -1,16 +1,25 @@
# frozen_string_literal: true
module CarrierWave
module Storage
class AliyunFile
+ attr_writer :file
attr_reader :uploader, :path
alias_method :filename, :path
alias_method :identifier, :filename
def initialize(uploader, base, path)
@uploader, @path, @base = uploader, escape(path), base
+ end
+
+ def file
+ @file ||= bucket.get(path).try(:first)
+ end
+
+ def size
+ file.headers[:content_length].to_i rescue nil
end
def escape(path)
CGI.escape(path).gsub("%2F", "/")
end