-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudinary.js
More file actions
35 lines (32 loc) · 758 Bytes
/
cloudinary.js
File metadata and controls
35 lines (32 loc) · 758 Bytes
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
var cloudinary = require('cloudinary').v2;
require("dotenv").config();
cloudinary.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_SECRET
});
exports.uploadImage = (file, folder) => {
return new Promise(resolve => {
cloudinary.uploader.upload(file,
{
upload_preset: 'InternetTimeline'
},
(err, result) => {
if(err) {
console.log('Error in uploading file');
console.log(err);
} else {
resolve({
url: result.secure_url,
id: result.public_id
})
}
},
{
resource_type: 'image',
folder: folder
}
)
})
}
exports.upload = cloudinary.uploader.upload;