'Failure to upload images from Strapi to a cloudinary folder

I'm working with Strapi v4.1.7 and I'm trying to upload my images to Cloudinary in a specific folder (portfolio) but they just get added to the root folder of cloudinary.

Also I'm using "@strapi/provider-upload-cloudinary": "^4.1.9", package.

My plugins.js is as follows:

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: "cloudinary",
      providerOptions: {
        cloud_name: env("CLOUDINARY_NAME"),
        api_key: env("CLOUDINARY_KEY"),
        api_secret: env("CLOUDINARY_SECRET"),
      },

      actionOptions: {
        upload: {
          folder: env("CLOUDINARY_FOLDER", "portfolio"),
        },
        delete: {},
      },
    },
  },
  // ...
});

Also in my .env file, I have the folder set as follows:

 ....
 CLOUDINARY_FOLDER=portfolio

Also, I was asking is it possible to create dynamic folders in Cloudinary like '/portfolio/Project1/all-project1-assets' from Strapi for all projects.

I need help to achieve this. Thanks !!!



Solution 1:[1]

Just change the Upload to uploadStream as highlighted below :

`actionOptions: {
   uploadStream: {
      folder: env("CLOUDINARY_FOLDER", "portfolio"),
    },
    delete: {},
  },

`

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eugene musebe