Search code examples
c#cloudinary

Cloudinary C# "File name must be specified in UploadParams!"


I'm working with cloudinary for keep my images in cloud. Following this Article for successfully update. I uploaded successfull once. After change my code somehow it doesn't work properly.

My Upload Method :


 var uploadParams = new ImageUploadParams
 {
     File = new FileDescription(imageDictionary[Consts.IMAGE_PATH]),
     UniqueFilename = false,
     UseFilename = true,
     PublicId = GetCloudinaryPublicId(imageDictionary[Consts.IMAGE_NAME]) 
 };

 ImageUploadResult? cloudUpdateResult;
 try
 {
     cloudUpdateResult = await _cloudinary.UploadAsync(uploadParams);
 }
 catch (Exception e)
 {
     return new ErrorResult(e.Message);
 }

Here imageDictionary returns image's physical path. For example wwwroot/images/userId/

And setted PublicId for cloudinary folder structure. For example images/userId/123123.jpg


When i try to upload an image (which exist in physical path) _cloudinary.UpdateAsync() throws exception, returns this message : "File name must be specified in UploadParams!"


Solution

  • I figure out that i'm giving just path to construstor wwwroot/images/userId and not giving imageName 123123.jpg

    After fixed it, it start work.

    File = new FileDescription(imageDictionary[Consts.IMAGE_PATH] + imageDictionary[Consts.IMAGE_NAME]),