> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET image and video upload


Cloudinary provides an API for uploading images, videos, and any other kind of file to the cloud. Files uploaded to Cloudinary are stored safely in the cloud with secure [backups and revision history](backups_and_version_management). Cloudinary's APIs allow secure uploading from your servers, directly from your visitors' browsers or mobile applications, or fetched via remote public URLs. 

Cloudinary's .NET SDK wraps Cloudinary's upload API and simplifies the integration. .NET methods are available for easily performing .NET image and video uploads to the cloud and .NET helper methods are available for uploading directly from a browser to Cloudinary.

This page covers common usage patterns for .NET image and video upload with Cloudinary.

For details on all available upload functionality, see the [Upload](upload_images) guide, and the [upload](image_upload_api_reference#upload) method of the Upload API Reference.
> **TIP**: Cloudinary's [Upload widget](upload_widget) provides an alternative to using a Cloudinary SDK to add upload functionality to your application, eliminating the need to develop in-house interactive upload capabilities. The upload widget is an interactive, feature rich, simple-to-integrate user interface that enables you to add Cloudinary upload support to your website. The widget can be easily embedded in your web application with just a few lines of JavaScript code. See the [Upload widget](upload_widget) documentation for detailed information. 

![Upload widget main screen](https://cloudinary-res.cloudinary.com/image/upload/q_auto/f_auto/bo_1px_solid_grey/docs/upload_widget_dev_default_new.png "width: 600, with_code:false, with_url:false")

## Server-side upload
  
You can upload images, videos, or any other raw file to Cloudinary from your .NET code. Uploading is done over HTTPS using a secure protocol based on your product environment's `api_key` and `api_secret` parameters. 
  
### .NET image upload

The following C# method uploads an image to the cloud:
  
```csharp
public ImageUploadResult Upload(ImageUploadParams parameters);
```

  The `ImageUploadParams` class sets an image to upload with additional parameters and `ImageUploadResult` class provides the deserialized server response.

For example, uploading a local image file named 'my\_image.jpg':

In C#:

 ```csharp
var uploadParams = new ImageUploadParams()
{
    File = new FileDescription(@"c:\my_image.jpg")
};
var uploadResult = cloudinary.Upload(uploadParams);
```

In VB.NET:

```csharp
Dim uploadParams = New ImageUploadParams
uploadParams.File = New FileDescription("c:\my_image.jpg")
Dim uploadResult = m_cloudinary.Upload(uploadParams)
```

> **NOTE**: If you need to override the default signing mechanism and supply your own [signature](authentication_signatures) for the upload, you can also pass the `signature` and `timestamp` parameters.

#### Customizing uploads
You can customize your upload by passing additional parameters in the options object. This allows you to assign metadata, organize assets, reuse filenames, request moderation, and more. For more details, see [Customizing uploads](upload_parameters).

**Example: Upload with tags, metadata, moderation, and analysis**

This example sets:

* **Tags**: `summer`, `new-arrival` 

* **Contextual metadata**:
  * Set the `department` as `apparel`
  * Set the `photographer` as `Jane Doe`

* **Structured metadata**:
  * Set the field with external ID `sku-id` as `SKU12345678`
  * Set the field with external ID `product-id` as `PROD-9081-WHT`

* **Additional options**:
  * `use_filename: true` – use original file name as the base for public ID
  * `unique_filename: true` – append a random suffix to avoid overwriting
  * `moderation: "webpurify"` – automatically flag assets for moderation
  * `quality_analysis: true` – request Cloudinary’s AI quality scoring

> **NOTE**:
>
> Before running this example in your product environment, [create](media_library_for_developers#managing_structured_metadata_fields) text fields with external IDs `sku-id` and `product-id`, and register for the **WebPurify** [add-on](cloudinary_add_ons). Replace `/home/my_image.jpg` with the path to an image in your local directory.
```csharp
var uploadParams = new ImageUploadParams()
{
    File = new FileDescription(@"C:\home\my_image.jpg"),
    UseFilename = true,
    UniqueFilename = true,
    Moderation = "webpurify",
    Tags = new List<string> { "summer", "new-arrival" },
    Context = new Dictionary<string, string>
    {
        { "department", "apparel" },
        { "photographer", "Jane Doe" }
    },
    MetadataFields = new StringDictionary
    {
        { "sku-id", "SKU12345678" },
        { "product-id", "PROD-9081-WHT" }
    },
    QualityAnalysis = true
};

var uploadResult = cloudinary.Upload(uploadParams);
```

For details on all available upload functionality, see the [Upload](upload_images) guide, and the [upload](image_upload_api_reference#upload) method of the Upload API Reference.

### .NET video upload

You upload videos in the same way as images. However, with videos, you must specify your parameters with the `VideoUploadParams` class. In addition, the `Upload` method supports uploading files up to 100 MB only. 

The following example uploads `dog.mp4` to Cloudinary and stores it  with the public ID `dog_closeup`. It also performs two eager transformations that resize the video to a square and a small rectangle.

```csharp
var uploadParams = new VideoUploadParams()
{
  File = new FileDescription(@"dog.mp4"),
  PublicId = "dog_closeup",
  EagerTransforms = new List<Transformation>()
  {
    new EagerTransformation().Width(300).Height(300).Crop("pad").AudioCodec("none"),
    new EagerTransformation().Width(160).Height(100).Crop("crop").Gravity("south").AudioCodec("none")),
  }
  EagerAsync = true,
  EagerNotificationUrl = "https://mysite.example.com/my_notification_endpoint"
};
var uploadResult = cloudinary.Upload(uploadParams);
```

### Upload large files

To upload files larger than 100 MB, use the [UploadLarge](upload_images#chunked_asset_upload) method, which uploads large files to the cloud in chunks.

The `UploadLarge` method has the identical signature and options as the `Upload` method, with the addition of an optional `bufferSize` parameter (default 20 MB).

For example, uploading a large video file named `my_large_video.mp4` and setting buffer size to 6 MB:

```csharp
var uploadParams = new VideoUploadParams(){ 
  File = new FileDescription(@"my_large_video.mp4")};
var uploadResult = cloudinary.UploadLarge(uploadParams, 6000000);
```

You can also upload your assets asynchronously in chunks with the `UploadLargeAsync` method.

The `UploadLargeAsync` method has a slightly different signature, and the same options as the `UploadLarge` method, with the addition of an optional `maxConcurrentUploads` parameter to limit the number of simultaneous uploads.

For example, uploading a large video file named `my_very_large_video.mp4` and setting buffer size to 5 MB, and a limit of 5 concurrent uploads:

```csharp
var uploadParams = new VideoUploadParams(){ 
  File = new FileDescription(@"my_very_large_video.mp4")};
var uploadResult = await cloudinary.UploadLargeAsync<VideoUploadResult>(uploadParams, 5000000, 5);
```

### Upload response

By default, uploading is performed synchronously. Once finished, the uploaded image is immediately available for transformation and delivery. You can also perform an asynchronous upload using the UploadAsync method.  See [Asynchronous API methods](dotnet_asset_administration#asynchronous_api_methods) for more information. 

An upload call returns a JSON object with content similar to the following:

```csharp
RESPONSE (ImageUploadResult):
{
    "asset_id": "86ca8ba13b17e21d23534b7e842b8847",
    "public_id": "do8wnccnlzrfvwv1mqkq",
    "version": 1719309138,
    "version_id": "1a2b0a8ef0bf8e9f20a922f38704eda6",
    "signature": "afb6a3374ba12e4e0307e23e625d939b242ddb5c",
    "width": 1920,
    "height": 1281,
    "format": "jpg",
    "resource_type": "image",
    "created_at": "2024-06-25T09:52:18Z",
    "tags": [],
    "bytes": 310479,
    "type": "upload",
    "etag": "a8f8236455d352b8cee6aba0e3fbc87e",
    "placeholder": false,
    "url": "http://res.cloudinary.com/cld-docs/image/upload/v1719309138/do8wnccnlzrfvwv1mqkq.jpg",
    "secure_url": "https://res.cloudinary.com/cld-docs/image/upload/v1719309138/do8wnccnlzrfvwv1mqkq.jpg",
    "asset_folder": "",
    "display_name": "do8wnccnlzrfvwv1mqkq",
    "original_filename": "f5lq8lfq8pfj0xmd9dak",
    "api_key": "614335564976464"
}
```

The response includes HTTP and HTTPS URLs for accessing the uploaded media asset as well as additional information regarding the uploaded asset: The public ID, resource type, width and height, file format, file size in bytes, a signature for verifying the response and more.  
  

## Direct uploading from the browser

The upload samples mentioned above allows your server-side .NET code to upload media assets to Cloudinary. In this flow, if you have a web form that allows your users to upload images or videos, the media file's data is first sent to your server and only then uploaded to Cloudinary. 

A more efficient and powerful option is to allow your users to upload images and videos in your client-side code directly from the browser to Cloudinary instead of going through your servers.  This method allows for faster uploading and better user experience. It also reduces load from your servers and reduces the complexity of your .NET applications.

You can upload files directly from the browser using signed or unsigned calls to the upload endpoint, as shown in the [Upload multiple files using a form](client_side_uploading#code_explorer_upload_multiple_files_using_a_form_unsigned) examples.

For signed uploads from your client-side code, a [secure signature](authentication_signatures) must be generated in your server-side .NET code. You can use the `SignParameters` method to [generate SHA signatures](authentication_signatures#using_cloudinary_backend_sdks_to_generate_sha_authentication_signatures):

```csharp
cloudinary.Api.SignParameters(IDictionary<string, object> parameters);
```

> **READING**:
>
> * For more information on uploading media assets, see the [Upload](upload_images) guide. 

> * For details on all available upload parameters, see the [upload](image_upload_api_reference#upload) method of the Upload API Reference.
