---
name: "DownloadTask.onProgressUpdate"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
platform:
  - "iOS"
  - "Android"
---

## DownloadTask.onProgressUpdate

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

### Description

Listen for download progress change events

### Parameters

`(listener: Function)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | Yes | - | Event listener callback function |

##### DownloadTask.onProgressUpdate.listener(params) properties

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `progress` | `number` | Yes | - | `2.0.1` | Download progress percentage |
| `totalBytesSent` | `number` | Yes | - | `2.0.1` | Downloaded data length, in Bytes |
| `totalBytesExpectedToSend` | `number` | Yes | - | `2.0.1` | Total expected data length to download, in Bytes |
| `requestId` | `string` | Yes | - | `2.0.1` | Network request ID |


### Examples

#### Demo

```tsx
import { downloadFile } from '@ray-js/ray'

// Listen for download progress: first get the download task handle via ty.downloadFile, then register a progress listener on the handle.
const downloadTask = await downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
});

downloadTask.onProgressUpdate(e => {
  console.log(e);
});
```
