Module: CarrierWave::FileCardUploader::Path
- Included in:
- CarrierWave::FileCardUploader
- Defined in:
- lib/carrier_wave/file_card_uploader/path.rb
Overview
path-related methods for uploader
Instance Method Summary collapse
- #cache_dir ⇒ Object
- #local_url(opts = {}) ⇒ Object
- #local_url_base(opts = {}) ⇒ Object
-
#path(version = nil) ⇒ Object
paperclip compatibility used in type/file.rb#core (base format).
- #public_path ⇒ Object
- #retrieve_path ⇒ Object
-
#store_path(for_file = nil) ⇒ Object
Carrierwave calls store_path without argument when it stores the file and with the identifier from the db when it retrieves the file.
- #tmp_path ⇒ Object
Instance Method Details
#cache_dir ⇒ Object
22 23 24 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 22 def cache_dir "#{@model.files_base_dir}/cache" end |
#local_url(opts = {}) ⇒ Object
9 10 11 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 9 def local_url opts={} "%s/%s/%s" % [local_url_base(opts), file_dir, full_filename(url_filename)] end |
#local_url_base(opts = {}) ⇒ Object
13 14 15 16 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 13 def local_url_base opts={} web_path = Card.config.files_web_path opts.delete(:absolute) ? card_url(web_path) : card_path(web_path) end |
#path(version = nil) ⇒ Object
paperclip compatibility used in type/file.rb#core (base format)
49 50 51 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 49 def path version=nil version ? versions[version].path : super() end |
#public_path ⇒ Object
18 19 20 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 18 def public_path File.join Cardio.paths["public"].existent.first, url end |
#retrieve_path ⇒ Object
39 40 41 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 39 def retrieve_path File.join([retrieve_dir, full_filename(filename)].compact) end |
#store_path(for_file = nil) ⇒ Object
Carrierwave calls store_path without argument when it stores the file and with the identifier from the db when it retrieves the file. In our case the first part of our identifier is not part of the path but we can construct the filename from db data. So we don’t need the identifier.
31 32 33 34 35 36 37 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 31 def store_path for_file=nil if for_file retrieve_path else File.join([store_dir, full_filename(filename)].compact) end end |
#tmp_path ⇒ Object
43 44 45 46 |
# File 'lib/carrier_wave/file_card_uploader/path.rb', line 43 def tmp_path Dir.mkdir model.tmp_upload_dir unless Dir.exist? model.tmp_upload_dir File.join model.tmp_upload_dir, filename end |