diff --git a/controllers/directoryController.js b/controllers/directoryController.js index 23dd507..88f0af0 100644 --- a/controllers/directoryController.js +++ b/controllers/directoryController.js @@ -3,13 +3,19 @@ import cloudinary from "cloudinary"; export const createDirectory = async (req, res) => { try { - const files = req.files.image; - // console.log(req.body) - // console.log(files) - const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { - folder: "cmp/image", - }, - function (error, result) { (result, error) }); + let image; + // console.log(req.files) + if (req.files !== null) { + const files = req.files.image; + const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { + folder: "cmp/image", + }, + function (error, result) { (result, error) }); + image = { + public_id: myCloud.public_id, + url: myCloud.secure_url, + } + } const { name, phone, @@ -43,10 +49,7 @@ export const createDirectory = async (req, res) => { LinkedinUrl, FacebookUrl, InstagramUrl, - image: { - public_id: myCloud.public_id, - url: myCloud.secure_url, - }, + image: image }); res.status(201).json({ diff --git a/tmp/tmp-1-1654869231487 b/tmp/tmp-1-1654869231487 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654869231487 differ diff --git a/tmp/tmp-1-1654869330605 b/tmp/tmp-1-1654869330605 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654869330605 differ diff --git a/tmp/tmp-1-1654875653394 b/tmp/tmp-1-1654875653394 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654875653394 differ diff --git a/tmp/tmp-1-1654875744407 b/tmp/tmp-1-1654875744407 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654875744407 differ diff --git a/tmp/tmp-1-1654876070898 b/tmp/tmp-1-1654876070898 new file mode 100644 index 0000000..62743be Binary files /dev/null and b/tmp/tmp-1-1654876070898 differ diff --git a/tmp/tmp-1-1654877661934 b/tmp/tmp-1-1654877661934 new file mode 100644 index 0000000..62743be Binary files /dev/null and b/tmp/tmp-1-1654877661934 differ