sud.downloadFile
JS
sud.downloadFile (Object object)Downloads a file resource to local storage.
The client directly issues an HTTP GET request and returns the local file path of the file. The maximum file size allowed for a single download is 50MB.
Parameters
- Object object: input parameters, described in the table below
object properties:
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | URL of the resource to download |
| header | Object | No | Header of the HTTP request; Referer cannot be set in the Header |
| timeout | number | No | Timeout, in milliseconds |
| filePath | string | No | Path where the downloaded file is stored |
| success | function | No | Callback function for a successful API call |
| fail | function | No | Callback function for a failed API call |
| complete | function | No | Callback function invoked when the API call ends |
Parameters of the success callback function
- Object res: returns the download information
res properties:
| Property | Type | Description |
|---|---|---|
| tempFilePath | string | Temporary file path. Returned when filePath is not passed to specify the storage path; the downloaded file is stored in the temporary directory |
| filePath | string | User file path. Returned when filePath is passed; identical to the passed filePath |
| statusCode | number | HTTP status code returned by the server |
Return Value
- DownloadTask: returns an object that can listen for download progress change events and cancel the download task
