There are 2 ways to bulk update tags. First is from the Media Library, and the second one is by using the Tags API.
Bulk update tags in the Media Library
Here is a short video illustrating the bulk update in Media Library
Using Tags API
Using API is a powerful way to manage your assets. The tags API is designed to handle programmatically tag updates.
Add tags
cloudinary.v2.uploader.add_tag(tag, public_ids, options).then(callback);
Remove tags
cloudinary.v2.uploader.remove_tag(tag, public_ids, options, callback);
Remove all tags
cloudinary.v2.uploader.remove_all_tags(public_ids, options).then(callback);
Replacing tags
cloudinary.v2.uploader.replace_tag(tag, public_ids, options, callback);
Samples
Node.js
cloudinary.v2.uploader .add_tag('animal', [ 'dog', 'lion' ]) .then(result=>console.log(result));
Python
result = cloudinary.uploader\ .add_tag("animal", ["dog", "lion"])
PHP
$result = $cloudinary->uploadApi() ->addTag('animal', ['dog', 'lion']);
Java
result = cloudinary.uploader() .addTag("animal", ["dog", "lion"], ObjectUtils.emptyMap());
You can even go further and keep a list of your assets and tags in a CSV. In the example, tags_update.csv contains the list of public_ids and tags to be used for programmatically updating the tags in your product environment.
tags_update.csv
publicid | tag |
publicd1 | tag1 |
publicd2 | tag2 |
Then iterate through the CSV file to update the tags.
Sample code in Java
try
{
BufferedReader br = new BufferedReader(new FileReader("tags_update.csv"));
while ((line = br.readLine()) != null) //returns a Boolean value
{
String[] result = line.split(splitBy); // use comma as separator
result[0] - public ID
result[1] - tag
output = cloudinary.uploader().addTag(result[1],
result[1], ObjectUtils.emptyMap());
}
}
catch (IOException e)
{
e.printStackTrace();
}
Comments
0 comments
Please sign in to leave a comment.