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

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.