How to upload multiple images to Cloudinary?

Asked

Viewed 77 times

2

I use Cloudinary to upload files to the cloud.

The following code works with 1 image, example:

var uploadParams = new ImageUploadParams()
{
    File = new FileDescription(@"C:\Users\Matheus Miranda\Pictures\Ferrai.jpg"),
    PublicId = "my_folder/images",
    EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);

In my folder contains 8 images, as I can upload several images ?

1 answer

2


On the estate PublicId, you need to put a different file name.

Example:

  • "my_folder/images/image1"
  • "my_folder/images/image2"
  • "my_folder/images/image3"

Follows code:

string[] files = 
    System.IO.Directory.GetFiles(@"C:\Users\Matheus Miranda\Pictures\teste", "*.jpg");

for (int i = 0; i < files.Length; i++)
{
    var uploadParams = new ImageUploadParams()
    {
        File = new FileDescription(files[i]),
        PublicId = $"my_folder/images/{System.IO.Path.GetFileName(files[i])}",
        EagerAsync = true
    };
    var uploadResult = cloudinary.Upload(uploadParams);
}
  • Burn? What do you mean?

  • And using the property UseFilename to true?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.