# Interface IMediaDownloader (1.73.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IMediaDownloader)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Download.IMediaDownloader)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Download.IMediaDownloader)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Download.IMediaDownloader)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Download.IMediaDownloader)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Download.IMediaDownloader)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Download.IMediaDownloader)

    public interface IMediaDownloader

Media download which uses download file part by part, by [ChunkSize](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IMediaDownloader#Google_Apis_Download_IMediaDownloader_ChunkSize).

## Namespace

[Google.Apis.Download](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download)

## Assembly

Google.Apis.dll

## Properties

### ChunkSize

    int ChunkSize { get; set; }

Gets or sets the chunk size to download, it defines the size of each part.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

## Methods

### Download(string, Stream)

    IDownloadProgress Download(string url, Stream stream)

Downloads synchronously the given URL to the given stream.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `stream` | `https://learn.microsoft.com/dotnet/api/system.io.stream` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IDownloadProgress` |   |

### DownloadAsync(string, Stream)

    Task<IDownloadProgress> DownloadAsync(string url, Stream stream)

Downloads asynchronously the given URL to the given stream.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `stream` | `https://learn.microsoft.com/dotnet/api/system.io.stream` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IDownloadProgress` |   |

### DownloadAsync(string, Stream, CancellationToken)

    Task<IDownloadProgress> DownloadAsync(string url, Stream stream, CancellationToken cancellationToken)

Downloads asynchronously the given URL to the given stream. This download method supports a cancellation
token to cancel a request before it was completed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `stream` | `https://learn.microsoft.com/dotnet/api/system.io.stream` |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IDownloadProgress` |   |

**Remarks** In case the download fails [Exception](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IDownloadProgress#Google_Apis_Download_IDownloadProgress_Exception) will contain the exception that
cause the failure. The only exception which will be thrown is
[TaskCanceledException](https://learn.microsoft.com/dotnet/api/system.threading.tasks.taskcanceledexception) which indicates that the task was canceled.

## Events

### ProgressChanged

    event Action<IDownloadProgress> ProgressChanged

An event which notifies when the download status has been changed.

| **Event Type** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Download.IDownloadProgress` |   |

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)