Strapi Cloudinary Upload Presets Help

I’ve been using the strapi-provider-upload-cloudinary package to connect with my Cloudinary media library, however, I cannot seem to get additional configuration items to work besides the ones required for the connection.

For example, I have upload presets set on Cloudinary, but when I add the value to the settings.json file, they don’t seem to get activated.

I have one that is supposed to organize the files uploaded into a folder, however the images get uploaded into the main space on Cloudinary, not into the folder.

Has anyone been able to get images to upload using a preset and the cloudinary provider?

//settings.json
{
“provider”: “cloudinary”,
“providerOptions”: {
“cloud_name”: “${process.env.CLOUDINARY_CLOUD_NAME}”,
“api_key”: “${process.env.CLOUDINARY_API_KEY}”,
“api_secret”: “${process.env.CLOUDINARY_API_SECRET}”,
“secure”: true,
“upload_preset”: “${process.env.CLOUDINARY_UPLOAD_PRESET}”

}

}

Hi @scottC you are probably using the old beta documentation from a google serach. We are aware of the improper SEO index and are working to fix it.

You should use the plugins.js settings file instead, see: https://strapi.io/documentation/v3.x/plugins/upload.html#enabling-the-provider
https://github.com/strapi/strapi/tree/master/packages/strapi-provider-upload-cloudinary#configurations

Hi @DMehaffy,

Thanks for the tip, was able to update the configuration so that it is now in the correct location, however I’m still not seeing the upload presets getting triggered.

I am able to successfully upload files to Cloudinary, but they don’t seem to be interacting with any of the upload presets.

I’ve tried including the upload presets inside and outside of the “params” object, and the assets still just go to the top level of my Cloudinary cloud.

//plugins.js
module.exports = ({ env }) => ({
upload: {
provider: ‘cloudinary’,
providerOptions: {
cloud_name: env(‘CLOUDINARY_CLOUD_NAME’),
api_key: env(‘CLOUDINARY_API_KEY’),
api_secret: env(‘CLOUDINARY_API_SECRET’),
secure: true,
upload_preset: env(‘CLOUDINARY_UPLOAD_PRESET’)
}
}
})

I have tried with a form in NextJS the past (non-Strapi app), and gotten the api to trigger properly, here’s an example of the function:

async function handleImageUpload () {
const data = new FormData();
data.append(‘file’, blogpost.media);
data.append(‘upload_preset’, process.env.CLOUDINARY_UPLOAD_PRESET);
data.append(‘cloud_name’, process.env.CLOUDINARY_CLOUD_NAME);
const response = await axios.post(process.env.CLOUDINARY_URL,data);
const mediaUrl = response.data.secure_url;
return mediaUrl;
}

This function would upload a file from the form and then return the url from Cloudinary to be stored in the database with the rest of blog fields in the form. The preset would organize the incoming images into a folder so that images from different websites would be stored separately.

I’ve not seen the upload_preset being used. I’ll try and do some testing to see if I can help.