Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar Upload failed #115

Open
moayaan1911 opened this issue Apr 26, 2024 · 8 comments
Open

Avatar Upload failed #115

moayaan1911 opened this issue Apr 26, 2024 · 8 comments

Comments

@moayaan1911
Copy link

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
Copy link
Author

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

Here is my repo

@pulkitgarg04
Copy link

pulkitgarg04 commented Apr 27, 2024

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
Copy link
Author

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

@pulkitgarg04
Copy link

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

@singh-43
Copy link

singh-43 commented May 25, 2024

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
Copy link

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

@Prince-Singh-05
Copy link

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

vishwamartur added a commit to vishwamartur/chai-backend that referenced this issue Oct 30, 2024
Related to hiteshchoudhary#115

Remove the deletion of local files after uploading to Cloudinary.

* Remove `fs.unlinkSync(localFilePath)` from `src/utils/cloudinary.js` to prevent deletion of local files after upload.
* Ensure the function `uploadOnCloudinary` returns the response from Cloudinary.
@muhammadshahbaz08
Copy link

muhammadshahbaz08 commented Dec 16, 2024

State to the Soltuiton:

  1. Load the dotenv file again ..in the cloudinary utility..

image

  1. when the upload gets failed to cloudinary the code given by hitesh sir, it automatically remove the file from temp folder ..if u want to keep them in the temp folder for checking ... comment the line highlighted

image

REASON:

I know thats not a good practice to call the dotenv file mupltiple times in your code , even though we had config them at our index.js ...but the solution i gave worked for me .After struggling with error for 3 days..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants