# Getting Started with WPF CloudUpload

This tutorial will walk you through the creation of a sample application that contains **RadCloudUpload**.

* [Adding Telerik Assemblies Using NuGet](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/getting-started#adding-telerik-assemblies-using-nuget)
* [Adding Assembly References Manually](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/getting-started#adding-assembly-references-manually)
* [Defining the UI](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/getting-started#defining-the-ui)
* [Creating the Provider](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/getting-started#creating-the-provider)

## Adding Telerik Assemblies Using NuGet

To use **RadCloudUpload** when working with NuGet packages, install the `Telerik.Windows.Cloud.Controls.for.Wpf.Xaml` package. The [package name may vary](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/available-packages) slightly based on the Telerik dlls set - [Xaml or NoXaml](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/xaml-vs-noxaml)

Read more about NuGet installation in the [Installing UI for WPF from NuGet Package](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/nuget-installation) article.

> tip With the 2025 Q1 release, the Telerik UI for WPF has a new licensing mechanism. You can learn more about it [here](https://www.telerik.com/products/wpf/documentation/installation/licensing/installing-license-key).

## Adding Assembly References Manually

If you are not using NuGet packages, you can add a reference to the following assemblies:

* **Telerik.Licensing.Runtime**
* **Telerik.Windows.Controls**
* **Telerik.Windows.Cloud**
* **Telerik.Windows.Cloud.Controls**

You can find the required assemblies for each control from the suite in the [Controls Dependencies](https://www.telerik.com/products/wpf/documentation/common-information/installation-installing-dependencies-wpf) help article.

## Defining the UI

The following example shows how to define a RadCloudUpload control and a RadCloudUploadList to show the selected files prepared for upload.

**Example 1: Defining RadCloudUpload and RadCloudUploadList**

```XAML
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <telerik:RadCloudUpload x:Name="RadCloudUpload" />
    <telerik:RadCloudUploadList Grid.Row="1" ItemsSource="{Binding Items, ElementName=RadCloudUpload}"/>
</Grid>
```

> The cloud upload control itself provides only a UI and an interface to execute the upload task. However, the upload process should be implemented with additional custom code. The next section shows how to set up this.

## Creating the Provider

RadCloudUpload uses a provider interface to upload files to the service of your choice. To create the provider you will need to define a class that implements the **ICloudUploadProvider** interface. The interface exposes a single method - **UploadFileAsync**, which returns a **Task\<object>** object.

This secion will show you how to create a dummy provider that stores the files in a storage in memory.

**Example 2: Creating a dummy storage and file classes**

```C#
public static class DummyStorage
{
    public static ObservableCollection<StorageFile> StorageFiles { get; private set; }

    static DummyStorage()
    {
        StorageFiles = new ObservableCollection<StorageFile>();
    }
}

public class StorageFile
{
    public string Name { get; set; }
    public long Size { get; set; }

    public StorageFile(string name, long size)
    {
        this.Name = name;
        this.Size = size;
    }
}
```

**Example 3: Implementing a dummy ICloudUploadProvider that uploads files to the storage**

```C#
public class DummyProvider : ICloudUploadProvider
{
    Random random = new Random();

    public Task<object> UploadFileAsync(string fileName, Stream fileStream, CloudUploadFileProgressChanged uploadProgressChanged, CancellationToken cancellationToken)
    {
        return System.Threading.Tasks.Task.Factory.StartNew<object>(() => UploadFile(fileName, fileStream, uploadProgressChanged, cancellationToken), cancellationToken);
    }

    private object UploadFile(string fileName, Stream fileStream, CloudUploadFileProgressChanged uploadProgressChanged, CancellationToken cancellationToken)
    {
        var fileLength = fileStream.Length;
        int uploadIterations = this.random.Next(10, 40);
        int chunkSize = (int)(fileLength / uploadIterations);

        for (int i = 0; i < uploadIterations; i++)
        {
            cancellationToken.ThrowIfCancellationRequested();
            uploadProgressChanged(i * chunkSize);
            Thread.Sleep(this.random.Next(200, 900));
        }

        uploadProgressChanged(fileLength);

        lock (DummyStorage.StorageFiles)
        {
            DummyStorage.StorageFiles.Add(new StorageFile(fileName, fileLength));
        }
        return fileName;
    }
}
```

**Example 4: Setting the provider**

```XAML
<telerik:RadCloudUpload>
    <telerik:RadCloudUpload.Provider>
        <local:DummyProvider />
    </telerik:RadCloudUpload.Provider>
</telerik:RadCloudUpload>
```

> The control doesn't have any built-in providers, but you can see how to implement one that connects to the Azure and Amazon services in the [RadCloudUpload SDK examples](https://github.com/telerik/xaml-sdk/tree/master/CloudUpload).

## Telerik UI for WPF Learning Resources

* [Telerik UI for WPF CloudUpload Component](https://www.telerik.com/products/wpf/cloud-upload.aspx)
* [Getting Started with Telerik UI for WPF Components](https://www.telerik.com/products/wpf/documentation/getting-started/first-steps-nuget)
* [Telerik UI for WPF Installation](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/installation-guide)
* [Telerik UI for WPF and WinForms Integration](https://www.telerik.com/products/wpf/documentation/common-information/winforms-integration/overview)
* [Telerik UI for WPF Visual Studio Templates](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/visual-studio-templates)
* [Setting a Theme with Telerik UI for WPF](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview)
* [Telerik UI for WPF Virtual Classroom (Training Courses for Registered Users)](https://learn.telerik.com/learn/course/external/view/elearning/16/telerik-ui-for-wpf)
* [Telerik UI for WPF License Agreement](https://www.telerik.com/purchase/license-agreement/wpf-dlw-s)

## See Also

* [RadCloudUploadList](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/radclouduploadlist)
* [Providers](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/providers)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/events)
* [Validation](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/validation)
