TypeError: Cannot read properties of undefined (reading 'secure_url') When i uploading image to cloudinary as const response = await uploadFileToCloudinary(file, "Mayank"); console.log(response); Then the response is printed as undefined and the error is provided #672
let path = __dirname + "/files/" + Date.now() + `.${file.name.split(".")[1]}` //jo bhi current working directory hogi usko __dirname show karta hai
console.log("Path->" , path);
file.mv(path, (error) =>{
console.log(error);
});
res.json({
success:true,
message:"Local file Uploaded successfully",
})
}
catch(error){
console.log("Not able to upload file");
console.log(error);
}
}
function isFileTypeSupported(type, supportedTypes){
return supportedTypes.includes(type);
}
const File = require("../model/File"); const cloudinary = require("cloudinary").v2; const mongoose = require("mongoose");
//local file upload exports.localFileUpload = async (req,res) => { try{ const file = req.files.file; console.log("file aagyi: " , file)
}
function isFileTypeSupported(type, supportedTypes){ return supportedTypes.includes(type); }
async function uploadFileToCloudinary(file,folder, quality){ const options = {folder}; if(quality){ options.quality = quality; } console.log("temp file pate is : " , file.tempFilePath); options.resource_type = "auto"; await cloudinary.uploader.upload(file.tempFilePath, options); }
exports.imageUpload = async(req,res) => { try{ //data fetch const {name, tags, email} = req.body; console.log(name,tags,email);