-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudConfig.js
executable file
·38 lines (34 loc) · 1.08 KB
/
cloudConfig.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
const cloudinary = require("cloudinary").v2;
const { CloudinaryStorage } = require("multer-storage-cloudinary");
// Cloudinary configuration using environment variables
cloudinary.config({
cloud_name: process.env.CLOUD_NAME,
api_key: process.env.CLOUD_API_KEY,
api_secret: process.env.CLOUD_SECRET_KEY,
});
// Set up CloudinaryStorage with allowed formats
const storage = new CloudinaryStorage({
cloudinary: cloudinary,
params: {
folder: "Cancer_Detection", // Cloudinary folder name
allowedFormats: ["png", "jpeg", "jpg", "pdf"], // Allowed file formats
fileFilter: (req, file) => {
// Define allowed MIME types for file upload
const allowedMimeTypes = [
"image/png",
"image/jpeg",
"image/jpg",
"application/pdf"
];
// Check if the file's MIME type is allowed
if (file.mimetype === 'application/pdf') {
// Accept the file
return true;
} else {
// Reject the file
return false;
}
}
},
});
module.exports = { cloudinary, storage };