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

Error while uploading profile image Cannot read properties of undefined (reading 'path') #619

Open
Mjashwanthh opened this issue Jul 17, 2023 · 1 comment

Comments

@Mjashwanthh
Copy link

Mjashwanthh commented Jul 17, 2023

const result = await cloudinary.v2.uploader.upload(req.file.path,{
public_id: ${user._id}_profile,
width: 500,
height: 500,
crop: 'fill',
});

@yadavritik467
Copy link

use this it will work also u need to create a folder as same as this folder: "music-image", where all the files will be stored then u will get your data

const profilePicture = req.body.file
        const user = await User.findById(req.user._id)

 const myCloud = await cloudinary.v2.uploader.upload(profilePicture, {
            folder: "music-image",
            resource_type: "auto",
        })
        user.profilePicture.public_id = myCloud.public_id
        user.profilePicture.url = myCloud.url
        await user.save()

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

2 participants