downloadFile method

Future<void> downloadFile({
  1. required String fileId,
  2. required String savePath,
  3. void onProcess(
    1. int count,
    2. int total
    )?,
})

下载文件

Implementation

Future<void> downloadFile(
    {required String fileId,
    required String savePath,
    void onProcess(int count, int total)?}) async {
  _checkParams("fileId", "fileId required");

  List<String> fileIds = [fileId];
  CloudBaseStorageRes<List<DownloadMetadata>> res =
      await getFileDownloadURL(fileIds);
  String? url = res.data[0].downloadUrl;
  if (url == null) {
    throw new CloudBaseException(
        code: CloudBaseExceptionCode.FILE_NOT_EXIST,
        message: 'File Not Exist');
  }
  await _request.download(url, savePath, onProcess);
}