Sarvesh Mokhare
Sarvesh Mokhare

Reputation: 1

"Upload preset must be specified when using unsigned upload" when trying to upload image from React to cloudinary

Even after making the Signing Mode to unsigned in the cloudinary->settings->upload->Upload presets, getting this error: "Upload preset must be specified when using unsigned upload". Here is my code for reference:

const cloudinaryData = new FormData();
    cloudinaryData.append("file", img);
    cloudinaryData.append("upload_preset", "preset-name");
    cloudinaryData.append("cloud_name", process.env.REACT_APP_CLOUDINARY_CLOUD_NAME);
    console.log(cloudinaryData);
    axios.post(`https://api.cloudinary.com/v1_1/${process.env.REACT_APP_CLOUDINARY_CLOUD_NAME}/upload`, {
        body: cloudinaryData,
    })
        .then(res => {
            res.json();
            console.log("from then", res);
        })
        .catch(err => {
            console.log("from catch", err);
        })

Upvotes: 0

Views: 619

Answers (1)

Tom
Tom

Reputation: 111

Your API URL is missing resource type, usually it has to be image, video or raw

Update to https://api.cloudinary.com/v1_1/${process.env.REACT_APP_CLOUDINARY_CLOUD_NAME}/image/upload (for images) and it should work

Upvotes: 0

Related Questions