Berlimioz / open_solidus_cloudinary

A solidus extension to use Cloudinary and Carrierwave instead of Paperclip
MIT License
3 stars 3 forks source link

How can I save images to a specific folder? #3

Open aaongr opened 5 years ago

aaongr commented 5 years ago

I would like to upload the images in a specific folder and not in the root of the cloudinary space... Any ideas how can I do this?

aaongr commented 5 years ago

I just had to override the public_id method. In config/initializers/solidus_cloudinary.rb:

module Cloudinary::CarrierWave
  def public_id
    # TODO: add/upload second file does not work! needs refresh page!
    return "#{Rails.application.class.parent_name.downcase}/#{File.basename(@filename.downcase, File.extname(@filename.downcase))}-#{Cloudinary::Utils.random_public_id}"
  end
end