/
manage.js
72 lines (60 loc) · 2.17 KB
/
manage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require('dotenv').config();
const cloudinary = require('cloudinary').v2;
//DOCS: https://cloudinary.com/documentation/managing_assets
// List all assets
// cloudinary.api.resources()
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// List all images with a given prefix
// cloudinary.api.resources({ type: 'upload', prefix: 'sample' })
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// Rename an asset
// cloudinary.uploader.rename("food/my_favorite/cheesecake", "my_cheesecake", {overwrite: true})
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// Destroy with Upload API
// cloudinary.uploader.destroy("my_cheesecake", {invalidate: true})
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// Delete multiple with Admin API
// cloudinary.api.delete_resources(["squirrel", "sheep"])
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// Upload and tag an asset
// cloudinary.uploader.upload("./assets/tag.jpg", {tags: "object, literally a tag"})
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// Tag an existing asset
// cloudinary.uploader.add_tag("animal", [ "cat" ])
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});
// cloudinary.uploader
// .add_tag('animal', 'dog',{resource_type:'video'})
// .then((result) => {
// console.log(result);
// })
// .catch((error) => {
// console.log(error);
// });
// Remove all tags from assets with public ID "cat" and "dog"
// cloudinary.uploader
// .remove_all_tags(['cat'])
// .then((result) => {
// console.log(result);
// })
// .catch((error) => {
// console.log(error);
// });
// cloudinary.uploader
// .remove_all_tags(['dog'], { resource_type: 'video' })
// .then((result) => {
// console.log(result);
// })
// .catch((error) => {
// console.log(error);
// });
// Rename an asset and invalidate
// cloudinary.uploader.rename("cat", "cute_cat", {invalidate: true})
// .then(result => {console.log(result)})
// .catch(error => {console.log(error)});