-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudConfig.js
More file actions
33 lines (28 loc) · 979 Bytes
/
cloudConfig.js
File metadata and controls
33 lines (28 loc) · 979 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
const cloudinary = require('cloudinary').v2;
const { CloudinaryStorage } = require('multer-storage-cloudinary');
// Verify credentials before configuration
if (!process.env.CLOUD_API_KEY) {
throw new Error('Cloudinary credentials missing in environment variables');
}
cloudinary.config({
cloud_name: process.env.CLOUD_NAME,
api_key: process.env.CLOUD_API_KEY,
api_secret: process.env.CLOUD_SECRET_KEY,
secure: true // Always use HTTPS
});
console.log('Cloudinary Configured:', {
cloud: cloudinary.config().cloud_name,
apiKey: cloudinary.config().api_key ? '***' : 'missing'
});
const storage = new CloudinaryStorage({
cloudinary: cloudinary,
params: {
folder: "Docflex_Dev",
allowed_formats: ['pdf', 'doc', 'docx', 'pptx', 'xlsx'],
resource_type: 'raw',
type: 'upload',
format: async (req, file) => path.extname(file.originalname).slice(1),
invalidate: true
}
});
module.exports = { cloud_storage: storage, cloudinary };