I am trying to upload a disk file via cloudinary in my JS file. im using multer as middleware and my uploadonCloudinary function
const uploadOnCloudinary = async (localFilePath) => {
try {
if (!localFilePath) return null
//upload the file on cloudinary
const response = await cloudinary.uploader.upload(localFilePath,{
resource_type: "auto"
})
//file has been uploaded successfull
console.log("file is uploaded on cloudinary ", response.url);
fs.unlinkSync(localFilePath)
return response;
} catch (error) {
console.error("error uploading",error);
fs.unlinkSync(localFilePath) // remove the locally saved temporary file as the upload operation got failed
return null;
}
}
# *gives me an error:
error uploading {
error: Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
at new NodeError (node:internal/errors:399:5)
at internalConnectMultiple (node:net:1099:20)
at Timeout.internalConnectMultipleTimeout (node:net:1638:3)
at listOnTimeout (node:internal/timers:575:11)
at process.processTimers (node:internal/timers:514:7) {
code: 'ERR_SOCKET_CONNECTION_TIMEOUT'
}
}
*
How to fix this been stuck since a long Time used different Stable Node versions
if any specific node version would help do share it and if any other method to resolve this error