downloadFile(params: Object)
Requires:
BaseKit≥2.3.2@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
Description
Download a file resource to local storage. The client directly initiates an HTTPS GET request and returns the file’s local temporary path (local path). The maximum file size per download is 200 MB. Read the related notes before use. Note: Specify an appropriate Content-Type header in the server response to ensure the client handles the file type correctly.
Parameters
| Property | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL of the resource to download |
| No | HTTP request headers; Referer cannot be set | ||
timeout | number | No | Timeout in milliseconds |
filePath | string | No | Path to store the downloaded file (local path) |
complete | () => void | No | Completion callback (executed on both success and failure) |
success | (params: Object) => void | No | Callback on successful API call |
fail | (params: Object) => void | No | Failure callback |
success callback parameters
| Property | Type | Description | BaseKit Since |
|---|---|---|---|
tempFilePath | string | Temporary file path (local path). Returned when filePath is not provided; the downloaded file is stored in a temporary file | v3.2.6 |
filePath | string | User file path (local path). Returned when filePath is provided; identical to the given filePath | v3.2.6 |
statusCode | number | HTTP status code returned by the developer server | v3.2.6 |
| Debug information during the request | v3.2.6 |
fail callback parameters
| Property | Type | Description |
|---|---|---|
errorMsg | string | Error message |
errorCode | string | number | Error code |
| Error extension |
Return Value
Type: DownloadTask
DownloadTask
| Property | Type | Description | BaseKit Since |
|---|---|---|---|
abort | function | Abort the download task | v2.0.1 |
onHeadersReceived | function | Listen for HTTP Response Header events. Fires before the request completion event | v2.0.1 |
offHeadersReceived | function | Stop listening for HTTP Response Header events | v2.0.1 |
onProgressUpdate | function | Listen for download progress change events | v2.0.1 |
offProgressUpdate | function | Stop listening for download progress change events | v2.0.1 |