Class: Tienda::ImageUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
app/uploaders/tienda/image_uploader.rb

Direct Known Subclasses

CategoryImageUploader, ProductImageUploader

Instance Method Summary collapse

Instance Method Details

#download_url(filename) ⇒ Object

You can find full list of custom headers in AWS SDK documentation on AWS::S3::S3Object



43
44
45
# File 'app/uploaders/tienda/image_uploader.rb', line 43

def download_url(filename)
  url(response_content_disposition: %Q{attachment; filename="#{filename}"})
end

#extension_white_listObject

Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:



37
38
39
# File 'app/uploaders/tienda/image_uploader.rb', line 37

def extension_white_list
  %w(jpg jpeg gif png)
end

#store_dirObject

Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:



11
12
13
# File 'app/uploaders/tienda/image_uploader.rb', line 11

def store_dir
  "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end