Folder creations are supported and you can find the full list of operations supported by the Media Library UI in our docs.
When uploading via API, you can specify the folder by using the "folder" parameter (use "asset_folder" for product environments using dynamic folder mode) OR you can include it as part of "public_id" (separated by a slash) and if the folder doesn't exist, it will automatically be created.
To specify subfolders, simply add a slash between each folder in the same string.
Here are two Ruby SDK code samples showing how to use both parameters (note - this requires the Gem v1.0.50+) using the Upload API:
Cloudinary::Uploader.upload("sample_image.jpg", :public_id => "<strong>multiple/folders/sample</strong>")
Cloudinary::Uploader.upload("sample_image.jpg", :folder => "<strong>multiple/folders</strong>", :public_id => "sample")
The above would result in this URL: http://res.cloudinary.com/demo/image/upload/v1364158979/multiple/folders/sample.jpg
It is important to note that by default, folders are part of an asset's "public ID" and URL delivery path. If you rename an asset or move it to another folder, you also modify its public ID path and thus can break links to assets in production.
To overcome this, you can use Dynamic folders where you can move assets freely in your account without the risk of breaking production URLs.
Comments
16 comments
I'm actually looking to do a similar thing. Is there an ETA on folders? What separators are supporting in the public ID because / is not and that would of course solve this issue..
Hi Eric,
There is no ETA yet. We will update you when we have more details.
You can use any standard separator (not slash...) to match your naming convention.
You can use a colon ':' as a separator. This character is not common in entity names and file names. For example: 'gallery:actors:john_doe'.
Thanks,
Nadav
UPDATE: Cloudinary supports folders as described in the updated article above.
I need to upload multiple files in a folder structure while preserving their names. How do you do that? it seems you can only create a folder through public_id, i've been using jquery plugin to do that, with the input file tag, if i use 'public_id' in the data-form-data field, it uploads only one file
Hi Sendy,
Currently it's needed to upload the files one-by-one. We're working on a solution for bulk uploads. This will allow specifying a folder name and allow "use filename" in parallel.
Hi,
Would it be possible to request a REST service in the Admin API that returns the complete folder structure for an account? I need something along those lines as I am writing a Cloudinary plugin module for a large CMS, and the end user must be able to sort through their image library by conventional means (i.e. folders).
Hi Erik,
Getting folder structure using our API is currently not supported. You can use the Admin API to search images by prefix that include the folder name. In addition, you can assign tags and then search images by tags.
Does your web based Media Library interface support folders and if so, how?
The public ID can contain folders, you can specify the desired public ID (e.g., "multiple/folders/sample") while uploading.
Public IDs can be specified in the Media library by clicking the "More upload options".
Is it possible to add folders when using Cloudinary::CarrierWave?
After chatting with cloudinary support, I can report that with the Cloudinary::CarrierWave plugin, you just do something like:
classPictureUploader** < *CarrierWave::Uploader::Base* **
include **Cloudinary*::CarrierWave*
...
**def ***public_id*
**return**** "*folder1/folder2/" + model.short_name*
**end**** **
end
Can you create a folder though the php API or a direct post? I need to allow my users to create folders regardless of any images in it.
Can I add a custom function in php to do a return $this->call_api("post", array("folders"), array(), $options);
While empty folders can be created via the Admin Console, currently the API doesn't support creating empty folders.
Folders are automatically created when uploading a new file. Either by including the folder as part of the
public_id
:\Cloudinary\Uploader::upload('my_image.jpg', array("public_id" => "my_folder/my_name"));
Or, by using the
folder
parameter:\Cloudinary\Uploader::upload('my_image.jpg', array("public_id" => "my_name", "folder" => "my_folder"));
Hi,
I had used following code
\Cloudinary\Uploader::upload(' Testimage.jpg', array("public_id" => "Abcd/Testimage"));
as well as
folder
parameter:\Cloudinary\Uploader::upload(' Testimage.jpg', array("public_id" => "Testimage", "folder" => "Abcd"));
but i get image name as : ** Abcd/Testimage.jpg**
and Url : http://res.cloudinary.com/armv/image/upload/v1421142637/Abcd/Testimage.jpg
there is no folder name "Abcd" in Media Library
Hi, i'm using wordpress, and I want to change my uploads folder to a folder in cloudinary. I've tried with a plugin without success. Could you tell me if it is possible? and how? thanks in advance, juan
Hi Abhishek,
You can enable folder's auto-creation inside the console (settings > upload > Auto-create folders)
Please note that this change will only affect new uploads.
Hi Juan,
There are several ways to upload images to cloudinary's account using Wordpress.
You can either directly upload it by using the Cloudinary Upload/Insert link inside [Posts > Edit post]
Or by first, uploading the images to the Wordpress media library and then migrate it to your cloudinary's account as described here:
https://wordpress.org/plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/faq/
If this doesn't solve your use-case please don't hesitate opening a support ticket:
http://support.cloudinary.com/tickets/new
Please sign in to leave a comment.