I have just started using Cloudinary to upload images for my client's project there & I was trying to upload an image using explanation provided here https://cloudinary.com/documentation/dotnet_image_upload but it's not working for me, can you explain a complete example of this? Or any link of tutorial will also help, thanks.
You can upload images on cloudinary following these steps for C# .NET
Install-Package CloudinaryDotNet?
using System.Collections.Generic;
using System.Web;
using CloudinaryDotNet;
using CloudinaryDotNet.Actions;?
var myAccount = new Account { ApiKey = apiKey, ApiSecret = apiSecret, Cloud = cloudName };
Cloudinary _cloudinary = new Cloudinary(myAccount);
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(@"c:\my_image.jpg");
};
var uploadResult = _cloudinary .Upload(uploadParams);??
uploadResult.SecureUri.AbsoluteUri;
var uploadParams = new ImageUploadParams {
File = new FileDescription(file.FileName,file.InputStream),
//transformation code here
Transformation = new Transformation().Width(200).Height(200).Crop("thumb").Gravity("face")
};
var uploadResult = _cloudinary.Upload(uploadParams);?
For Video upload use C# code as
var uploadParams = new VideoUploadParams()
{
File = new FileDescription(@"dog.mp4"),
ResourceType = "video"
PublicId = "my_folder/my_sub_folder/my_dog",
Overwrite = true,
NotificationUrl = "http://mysite/my_notification_endpoint"
};
var uploadResult = cloudinary.Upload(uploadParams);
The video will overwrite the existing my_dog
video if it exists. When the video upload is complete, the specified notification URL will receive details about the uploaded media asset.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly