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

PropertyType

Required

Description
urlStringYesDownloading file address.
headerObjectNoHTTP request Header.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback 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:

PropertyTypeDescription
apFilePathStringTemporary file storage location.

Error Code

ErrorDescription
12Downloading failed.
13No right.