hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.36k stars 803 forks source link

Avatar Upload failed #115

Open moayaan1911 opened 7 months ago

moayaan1911 commented 7 months ago

Screenshot 2024-04-26 130431 I noticed that in my public folder the images I am sending from postman is NOT GETTING stored, I tried debugging it but couldn't find the solution

moayaan1911 commented 7 months ago

https://github.com/moayaan1911/backend-mastery

Here is my repo

pulkitgarg04 commented 7 months ago

Hey, I encountered a similar issue as well. The problem arose due to a configuration error in my Cloudinary configuration setup. After addressing the issue by adjusting my Cloudinary settings, my problem was resolved. I suggest reviewing your Cloudinary configuration to ensure it is properly configured.

moayaan1911 commented 6 months ago

But my images are not getting stores in local public folder either..

pulkitgarg04 commented 6 months ago

That can be because of fs.unlinkSync(localFilePath) used in Cloudinary.js file, try removing this line from the file.

singh-43 commented 6 months ago

The problem is because your dotenv file is not configured properly. To check this in cloudinary upload function do a console.log(process.env.CLOUDINARY_SECRET_KEY) ( whatever name you have given ). If you are getting null in terminal, then below configuration will work. First close the server manually, nodemon restarting wont work. Then in your index.js file in project root directory write this instead

dotenv.config({
    path: './.env'
})

And in package.json write this script

"scripts": {
    "dev": "nodemon -r dotenv/config --experimental-json-modules src/index.js"
  },

Now restart your server manually not through nodemon.

Harmain89 commented 4 months ago

try after re-select the file in postman. It happens sometimes.

Prince-Singh-05 commented 3 months ago

I also encountered this issue that my images were not getting stored in the public folder but removing all fields from Postman and re-entering the fields in form data worked for me

Try it once