my.downloadFile
Download a file resource to a local location.
Supported types of mini programs: DSL, H5+
Sample code
copy
my.downloadFile({
url: 'https://alidata-pub.oss-cn-hangzhou.aliyuncs.com/test.pdf',
success(res) {
console.log('downloadFile Success:', JSON.stringify(res, null, 2))
},
fail(res) {
console.log('downloadFile Failed:', JSON.stringify(err, null, 2))
},
});Parameters
| Property | Type | Required | 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:
| Property | Type | Description |
| apFilePath | String | Temporary file storage location. |
Error Code
| Error | Description |
| 12 | Downloading failed. |
| 13 | No right. |