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
strapi/packages/strapi-provider-upload-cloudinary at master · strapi/strapi · GitHub

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.

Hi,
I am facing the same issue. My plugin.js is configured like so:

module.exports = ({ env }) => ({
    upload: {
        provider: 'cloudinary',
        providerOptions: {
            cloud_name: env('CLOUDINARY_NAME'),
            api_key: env('CLOUDINARY_KEY'),
            api_secret: env('CLOUDINARY_SECRET'),
            upload_preset: env('CLOUDINARY_UPLOAD_PRESET'),
        },
    },
});

but the upload preset is ignored. I am trying to upload images to a specific folder and apply some async transformation.

Resources:
https://cloudinary.com/documentation/cloudinary_sdks#configuration_parameters

I’ve given up on the upload presets for this reason, even though it should work it doesn’t appear that it passes this information to cloudinary.

this is the right configuration

upload: {
    provider: 'cloudinary',
    providerOptions: {
      cloud_name: env('CLOUDINARY_NAME'),
      api_key: env('CLOUDINARY_KEY'),
      api_secret: env('CLOUDINARY_SECRET'),
    },
    actionOptions: {
      upload: env(‘CLOUDINARY_UPLOAD_PRESET’),
      delete: {},
    },
  },

I hope this helps someone out

you could as well put the “upload_preset” directly here, for example “folder”

upload: {
    provider: 'cloudinary',
    providerOptions: {
      cloud_name: env('CLOUDINARY_NAME'),
      api_key: env('CLOUDINARY_KEY'),
      api_secret: env('CLOUDINARY_SECRET'),
    },
    actionOptions: {
      upload: {
        folder: "folder-name",
      },
      delete: {},
    },
  },