my.downloadFile
Download a file resource to a local location.
Sample Code
copy
my.downloadFile({
url: 'http://img.example.com/example.jpg',
success({ apFilePath }) {
my.previewImage({
urls: [apFilePath],
});
},
fail(res) {
my.alert({
content: res.errorMessage || res.error,
});
},
});
Parameters
Name | Type | Mandatory | Description |
url | String | Yes | Downloading file address |
header | Object | No | HTTP request Header |
success | Function | No | Callback function upon call success |
fail | Function | No | Callback function upon call failure |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure) |
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Name | Type | Description |
apFilePath | String | Temporary file storage location |
Error Code
error | Description |
12 | Downloading failed |
13 | No right |