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

NameTypeMandatoryDescription
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:

NameTypeDescription
apFilePathStringTemporary file storage location

Error Code

errorDescription
12Downloading failed
13No right