downloadKbFile static method

Future<void> downloadKbFile(
  1. String fileId,
  2. String fileName,
  3. String assistandId,
  4. String conversationId,
  5. bool isMarketplace,
)

Implementation

static Future<void> downloadKbFile(String fileId, String fileName,
    String assistandId, String conversationId, bool isMarketplace) async {
  String url = ApiUrls.fileDownloadUrl(assistandId, conversationId, fileId, isMarketplace: isMarketplace);
  await ApiService.call(url, RequestType.get,
      onSuccess: (response) async {
    String downloadUrl = response.data["signedUrl"];
    Directory downloadDirectory = await getDownloadDirectory();
    String fullPath = "${downloadDirectory.path}/$fileName";
    await ApiService.download(
      url: downloadUrl,
      savePath: fullPath,
      onSuccess: () => showFeedbackSnackbar(
          Strings.fileDownloadSuccess.tr, Symbols.download),
      onError: (e) => showErrorSnackbar(Strings.fileDownloadFail.tr),
    );
  });
}