If you’ve encountered the “Upload preset not found” error while using Cloudinary as your image storage solution, don’t worry! This issue can be easily fixed by following a few simple steps.
-
Access Your Cloudinary Dashboard
- Log in to your Cloudinary account and navigate to the Settings section.
-
Add an Upload Preset
- In the Settings area, locate the Upload tab and click on it.
- Look for the “Add upload preset” button and click on it to create a new upload preset.
-
Configure the Upload Preset
- Provide a name for the upload preset. Make sure to choose a meaningful and descriptive name that represents its purpose.
- Set any additional options or parameters as per your requirements.
-
Use the Preset Name in Your Upload Code
- Once you’ve created the upload preset, you’ll need to use its name in your Cloudinary upload code.
- For example, if you have an HTML canvas object called
canvas
and want to upload it as an image to Cloudinary, you can use the following code snippet:
const base64Image = canvas.toDataURL()
const formData = new FormData()
formData.append('file', base64Image)
formData.append('upload_preset', 'YOUR_PRESET_NAME')
fetch(`https://api.cloudinary.com/v1_1/YOUR_CLOUD_NAME/image/upload`, {
method: 'POST',
body: formData,
})
- Consider Using an Unsigned Upload Preset for Testing
- During testing and development, you may find it convenient to utilize an unsigned upload preset. This simplifies the process and reduces the need for additional authentication steps.
Following these steps should resolve the “Upload preset not found” error and allow you to successfully upload your images to Cloudinary.