Class: Resizing::CarrierWave::Storage::Remote

Inherits:
CarrierWave::Storage::Abstract
  • Object
show all
Defined in:
lib/resizing/carrier_wave/storage/remote.rb

Overview

Instance Method Summary collapse

Instance Method Details

#cache!(new_file) ⇒ Object



27
28
29
30
31
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 27

def cache!(new_file)
  f = Resizing::CarrierWave::Storage::File.new(uploader)
  f.store(new_file)
  f
end

#clean_cache!(seconds) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 42

def clean_cache!(seconds)
  # do nothing
  #
  # connection.directories.new(
  #   :key    => uploader.fog_directory,
  #   :public => uploader.fog_public
  # ).files.all(:prefix => uploader.cache_dir).each do |file|
  #   # generate_cache_id returns key formated TIMEINT-PID(-COUNTER)-RND
  #   time = file.key.scan(/(\d+)-\d+-\d+(?:-\d+)?/).first.map { |t| t.to_i }
  #   time = Time.at(*time)
  #   file.destroy if time < (Time.now.utc - seconds)
  # end
end

#delete_dir!(path) ⇒ Object



38
39
40
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 38

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

#remove!(file) ⇒ Object



16
17
18
19
20
21
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 16

def remove!(file)
  f = Resizing::CarrierWave::Storage::File.new(uploader)
  f.delete(file)
  @filename = f.public_id.to_s
  f
end

#retrieve!(identifier) ⇒ Object



23
24
25
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 23

def retrieve!(identifier)
  Resizing::CarrierWave::Storage::File.new(uploader, identifier)
end

#retrieve_from_cache!(identifier) ⇒ Object



33
34
35
36
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 33

def retrieve_from_cache!(identifier)
  # NOP
  # Resizing::CarrierWave::Storage::File..new(uploader, uploader.cache_path(identifier))
end

#store!(file) ⇒ Object



9
10
11
12
13
14
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 9

def store!(file)
  f = Resizing::CarrierWave::Storage::File.new(uploader)
  f.store(file)
  @filename = f.public_id.to_s
  f
end