How to upload images to folders with CarrierWave

When using Carrierwave with server-side uploads, you can use a code like the following:

classPictureUploader < CarrierWave::Uploader::Base      
  include Cloudinary::CarrierWave

  def public_id
    return "my_folder/" + model.short_name

If you're using client-side upload, you can set the folder parameter when building the upload tag:

<%= f.cl_image_upload(:image, :folder => "my_folder") %>

In order to sync the folders in the Media library with the created folders from the API, you should enable 'Auto-create folders' from the Upload settings page. This will be applied to all newly created folders.

Have more questions? Submit a request


  • Avatar

    Do I must define a public_id with server-side? I only wanna create a folder and mantain the default public_id.

    Is it possible?

    Edited by Sanson
  • Avatar
    Nadav Ofir

    Hi, you can use our random_public_id method to generate a random public ID for the upload request, e.g.:

      def public_id
        return "my_folder/" + Cloudinary::Utils.random_public_id;
    Edited by Nadav Ofir
  • Avatar
    Pedro Henrique Knoll Giacometo

    How can I use the

    <%= f.cl_image_upload(:image, :folder => "my_folder") %>

    with simple_form?

    Edited by Pedro Henrique Knoll Giacometo
  • Avatar
    Maor Gariv

    Sorry for the very late reply, we have noticed that this request was left unattended. I guess this is not relevant anymore but if you have any further questions, feel free to reach out by opening a new support ticket -

Powered by Zendesk