I'm trying to upload files (images, to be precise) to Cloudinary. In Cloudinary's documentation for .NET (Documentation), it's said that files should be uploaded like this:
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(@"c:\sample.jpg")
};
var uploadResult = cloudinary.Upload(uploadParams);
So basically, I need file path to upload an image. When I hard-code the path it works, but I want the user be able to choose his own files, obviously. The only way to get the files that I have found was using IFormFile, but the only way I can upload file using it is by uploading it to server first, and then getting the path of the uploaded file and forwarding it to Cloaudinary, but there must be a better way.
So how can I let user upload files to Cloudinary using ASP.NET Core?
public ImageUploadResult UploadImage(HttpPostedFileBase file) { if (file != null) { var uploadParams = new ImageUploadParams { File = new FileDescription(file.FileName, file.InputStream), Transformation = new Transformation().Width(200).Height(200).Crop("thumb").Gravity("face") }; var uploadResult = _cloudinary.Upload(uploadParams); return uploadResult; } return null; }