Sha256: 53fc0945ae592abde8f534363193ef0c5b6446afd92249cb17f69cbebcaf8b3b
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
module CarrierWave module Storage class AliyunFile < CarrierWave::SanitizedFile attr_reader :path def initialize(uploader, base, path) @uploader = uploader @path = URI.encode(path) @base = base end def read object = bucket.get(@path) @headers = object.headers object end def delete bucket.delete(@path) true rescue => e # If the file's not there, don't panic puts "carrierwave-aliyun delete file failed: #{e}" nil end ## # Generate file url # params # :thumb - Aliyun OSS Image Processor option, etc: @100w_200h_95q # def url(opts = {}) if @uploader.aliyun_private_read bucket.private_get_url(@path, opts) else bucket.path_to_url(@path, opts) end end def content_type headers[:content_type] 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 def bucket return @bucket if defined? @bucket @bucket = CarrierWave::Aliyun::Bucket.new(@uploader) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
carrierwave-aliyun-0.8.1 | lib/carrierwave/storage/aliyun_file.rb |
carrierwave-aliyun-0.7.1 | lib/carrierwave/storage/aliyun_file.rb |