To use the SDK in a .NET project, first install the SDK:
dotnet add package CloudinaryDotNetThen, add the necessary package reference
using CloudinaryDotNet;
using CloudinaryDotNet.Actions;Finally, configure a new instance of Cloudinary:
Account account = new Account(
"<Your Cloud Name>",
"<Your API Key>",
"<Your API Secret>");
Cloudinary cloudinary = new Cloudinary(account);Finally, run the upload method, passing in your image source:
var uploadParams = new ImageUploadParams()
{
File = new FileDescription("<Image Location or URL>")
};
var uploadResult = await cloudinary.UploadAsync(uploadParams);- Add the following environment variables via your shell
# In Bash
export CLOUDINARY_CLOUD_NAME=<Your Cloud Name>
export CLOUDINARY_API_KEY=<Your API Key>
export CLOUDINARY_API_SECRET=<Your API Secret>
# Or
# In CMD
set CLOUDINARY_CLOUD_NAME="<Your Cloud Name>"
set CLOUDINARY_API_KEY="<Your API Key>"
set CLOUDINARY_API_SECRET="<Your API Secret>"- Install the project dependencies with:
dotnet restore- Run the program with:
dotnet runThe program will run in your terminal and you'll see the URL results logged.