forked from Deen-Bridge/dnb-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadController.js
More file actions
30 lines (28 loc) · 854 Bytes
/
Copy pathuploadController.js
File metadata and controls
30 lines (28 loc) · 854 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
import cloudinary from "../utils/cloudinary.js";
import logger from "../config/logger.js";
export const generateSignature = async (req, res) => {
try {
const timestamp = Math.round(new Date().getTime() / 1000);
const config = cloudinary.config();
const signature = cloudinary.utils.api_sign_request(
{
timestamp,
folder: "direct-uploads",
},
config.api_secret
);
res.status(200).json({
success: true,
message: "Signature generated successfully",
data: {
timestamp,
signature,
cloudName: config.cloud_name,
apiKey: config.api_key,
}
});
} catch (error) {
logger.error("Error generating Cloudinary signature:", error);
res.status(500).json({ success: false, message: "Failed to generate upload signature", data: null });
}
};