Class: MailAttachmentUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- MailAttachmentUploader
- Includes:
- CarrierWave::MimeTypes
- Defined in:
- lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb
Overview
encoding: utf-8
Defined Under Namespace
Classes: MimeIO
Class Method Summary collapse
Instance Method Summary collapse
-
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded.
-
#filename ⇒ Object
Override the filename of the uploaded files: Avoid using model.id or version_name here, see uploader/store.rb for details.
-
#store_dir ⇒ Object
Override the directory where uploaded files will be stored.
- #store_mime(fname, mime_blob) ⇒ Object
Class Method Details
.delete(filename) ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb', line 27 def self.delete(filename) return if filename.blank? filepath = File.join(new.store_dir, filename) File.delete(filepath) if File.exists?(filepath) end |
.flush ⇒ Object
24 25 26 |
# File 'lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb', line 24 def self.flush Dir.glob(File.join(new.store_dir, '*')).each{|f| File.delete(f)} end |
Instance Method Details
#extension_white_list ⇒ Object
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:
52 53 54 |
# File 'lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb', line 52 def extension_white_list %w(csv zip) end |
#filename ⇒ Object
Override the filename of the uploaded files: Avoid using model.id or version_name here, see uploader/store.rb for details.
58 59 60 |
# File 'lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb', line 58 def filename original_filename.squish.gsub(" ", "_") end |
#store_dir ⇒ Object
Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:
40 41 42 |
# File 'lib/generators/mastiff/install/templates/carrierwave/mail_attachment_uploader.rb', line 40 def store_dir Mastiff. end |