Class: CarrierWave::Storage::Qiniu

Inherits:
Abstract
  • Object
show all
Defined in:
lib/carrierwave/storage/qiniu.rb

Instance Method Summary collapse

Instance Method Details

#cache!(file) ⇒ Object



11
12
13
14
15
# File 'lib/carrierwave/storage/qiniu.rb', line 11

def cache!(file)
  QiniuFile.new(uploader, uploader.cache_path).tap do |qiniu_file|
    qiniu_file.store(file)
  end
end

#clean_cache!(seconds) ⇒ Object



32
33
34
35
# File 'lib/carrierwave/storage/qiniu.rb', line 32

def clean_cache!(seconds)
  # 如果缓存目录在云端,建议使用七牛云存储的生命周期设置, 以减少主动 API 调用次数
  raise 'Use Qiniu Object Lifecycle Management to clean the cache'
end

#delete_dir!(path) ⇒ Object

Deletes a cache dir



28
29
30
# File 'lib/carrierwave/storage/qiniu.rb', line 28

def delete_dir!(path)
  # do nothing, because there's no such things as 'empty directory'
end

#retrieve!(identifier) ⇒ Object



17
18
19
# File 'lib/carrierwave/storage/qiniu.rb', line 17

def retrieve!(identifier)
  QiniuFile.new(uploader, uploader.store_path(identifier))
end

#retrieve_from_cache!(identifier) ⇒ Object



21
22
23
# File 'lib/carrierwave/storage/qiniu.rb', line 21

def retrieve_from_cache!(identifier)
  QiniuFile.new(uploader, uploader.cache_path(identifier))
end

#store!(file) ⇒ Object



5
6
7
8
9
# File 'lib/carrierwave/storage/qiniu.rb', line 5

def store!(file)
  QiniuFile.new(uploader, uploader.store_path).tap do |qiniu_file|
    qiniu_file.store(file)
  end
end