Class: Resizing::CarrierWave::Storage::Remote
- Inherits:
-
CarrierWave::Storage::Abstract
- Object
- CarrierWave::Storage::Abstract
- Resizing::CarrierWave::Storage::Remote
- Defined in:
- lib/resizing/carrier_wave/storage/remote.rb
Overview
Instance Method Summary collapse
- #cache!(new_file) ⇒ Object
- #clean_cache!(seconds) ⇒ Object
- #delete_dir!(path) ⇒ Object
-
#remove!(file = nil) ⇒ Object
NOTE: CarrierWave 2.2.x never reaches here (Uploader::Remove#remove! calls File#delete takes no argument and resolves the image to delete by itself, so reuse the given file when it is already ours instead of building a new one..
- #retrieve!(identifier) ⇒ Object
- #retrieve_from_cache!(identifier) ⇒ Object
- #store!(file) ⇒ Object
Instance Method Details
#cache!(new_file) ⇒ Object
33 34 35 36 37 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 33 def cache!(new_file) f = Resizing::CarrierWave::Storage::File.new(uploader) f.store(new_file) f end |
#clean_cache!(seconds) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 48 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
44 45 46 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 44 def delete_dir!(path) # do nothing, because there's no such things as 'empty directory' end |
#remove!(file = nil) ⇒ Object
NOTE: CarrierWave 2.2.x never reaches here (Uploader::Remove#remove! calls File#delete takes no argument and resolves the image to delete by itself, so reuse the given file when it is already ours instead of building a new one.
19 20 21 22 23 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 19 def remove!(file = nil) f = file.is_a?(Resizing::CarrierWave::Storage::File) ? file : Resizing::CarrierWave::Storage::File.new(uploader) f.delete f end |
#retrieve!(identifier) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 25 def retrieve!(identifier) return nil if identifier.blank? f = Resizing::CarrierWave::Storage::File.new(uploader, identifier) f.retrieve(identifier) f end |
#retrieve_from_cache!(identifier) ⇒ Object
39 40 41 42 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 39 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 |
# File 'lib/resizing/carrier_wave/storage/remote.rb', line 9 def store!(file) f = Resizing::CarrierWave::Storage::File.new(uploader) f.store(file) f end |