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 end end
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.
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?
Hi, you can use our random_public_id method to generate a random public ID for the upload request, e.g.:
How can I use the
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 -
Hi Maor Gariv/Itay Taragano,
As updated recently by Itay Taragano, using public_id in the uploader class doesn't update the URL structure.
And URL generated still looks like this: "https://res-3.cloudinary.com/cloud_name/image/upload/pic_08.png"
And my public_id method looks as follows:
It still uses the `resource_type` and `type` instead of my model details as mentioned above. And i followed all the steps mentioned.
To save the `public_id` with that structure to your uploader, you can do the following:
Let me know if this works for you.
Please sign in to leave a comment.