-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpublic-id.js
53 lines (48 loc) · 1.53 KB
/
public-id.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
require("dotenv").config();
const cloudinary = require("cloudinary").v2;
// Public ID - Naming Options
// local asset
// default - 20 random characters
// cloudinary.uploader
// .upload("./assets/hiker.jpg")
// .then((result) => {
// console.log("------------DEFAULT------------------");
// console.log(result);
// console.log("-------------------------------------");
// })
// .catch((error) => {
// console.log(error);
// });
// file name + unique 6 random character suffix
// cloudinary.uploader
// .upload("./assets/hiker.jpg", { use_filename: true, unique_filename: true })
// .then((result) => {
// console.log("------------FILENAME + UNIQUE----------");
// console.log(result);
// console.log("-------------------------------------");
// })
// .catch((error) => {
// console.log(error);
// });
// use filename + no randomization
cloudinary.uploader
.upload("./assets/hiker.jpg", { use_filename: true, unique_filename: false })
.then((result) => {
console.log("--------FILENAME + NOT UNIQUE----------");
console.log(result);
console.log("-------------------------------------");
})
.catch((error) => {
console.log(error);
});
// specify public ID
// cloudinary.uploader
// .upload("./assets/hiker.jpg", { public_id: "mountain-123" })
// .then((result) => {
// console.log("--------SPECIFY PUBLIC ID-------------");
// console.log(result);
// console.log('-------------------------------------');
// })
// .catch((error) => {
// console.log(error);
// });