When using CarrierWave to perform server-side uploads, you can use code like the following:
classPictureUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave ... def public_id return "my_folder/" + model.short_name end end
Alternatively, if you would like to use a random public ID (because that may be default behavior for your uploads), you can use the following for public_id
:
return "my_folder/" + Cloudinary::Utils.random_public_id;
If you're using client-side uploads, you can set the folder
parameter when building the upload tag:
<%= f.cl_image_upload(:image, :folder => "my_folder") %>
For more information on the CarrierWave integration, please refer to the CarrierWave integration reference.
Comments
6 comments
Hi, you can use our random_public_id method to generate a random public ID for the upload request, e.g.:
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.
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?
How can I use the
with simple_form?
Hi,
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 -
https://support.cloudinary.com/hc/en-us/requests/new
Hi,
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.