Class: CustomFields::Types::File::FileUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- CustomFields::Types::File::FileUploader
- Defined in:
- lib/locomotive/custom_fields.rb
Instance Method Summary collapse
- #cache_dir ⇒ Object
-
#guess_url(host = nil) ⇒ String
In some situations, for instance, for the notification email when a content entry is created, we need to know the url of the file without breaking the upload process.
- #image? ⇒ Boolean
-
#store_dir ⇒ Object
Set correct paths.
Methods inherited from CarrierWave::Uploader::Base
#build_store_dir, #to_label, #to_liquid
Methods included from CarrierWave::Uploader::Base64Download
Instance Method Details
#cache_dir ⇒ Object
65 66 67 |
# File 'lib/locomotive/custom_fields.rb', line 65 def cache_dir "#{Rails.root}/tmp/uploads" end |
#guess_url(host = nil) ⇒ String
In some situations, for instance, for the notification email when a content entry is created, we need to know the url of the file without breaking the upload process. Actually, the uploaded file will be written on the filesystem after the email is sent.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/locomotive/custom_fields.rb', line 54 def guess_url(host = nil) this = self.class.new(model, mounted_as) this.retrieve_from_store!(model.read_uploader(mounted_as)) if this.url =~ /^http/ || host.blank? this.url else URI.join("http://#{host}", this.url).to_s end end |
#image? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/locomotive/custom_fields.rb', line 40 def image? !(content_type =~ /image/).nil? rescue Exception => e Rails.logger.error("[CustomFields][FileUploader][#{model._id}] can't access the uploaded file, reason: #{e.}") end |
#store_dir ⇒ Object
Set correct paths
36 37 38 |
# File 'lib/locomotive/custom_fields.rb', line 36 def store_dir "sites/#{model.site_id}/#{model._type.demodulize.underscore}/#{model.id}/files" end |