react native – download file on ios emulator


const downloadFile = async (file: IFile) => {
    const isGranted = await getPermissionDownloadImage();

    if (!isGranted) {
      toast.current?.show("Отсутствует разрешение на загрузку документов");
      return;
    }

    const url = `${ConnectionStore.api}longreads/file/${file.id}`;
    const headers = { Authorization: `Bearer ${keycloak.token}` };

    await ReactNativeBlobUtil.config({
      fileCache: true,
      path: IS_IOS
        ? `${RNFS.DocumentDirectoryPath}/${file.fileName}.${file.extension}`
        : `${RNFS.DownloadDirectoryPath}/${file.fileName}.${file.extension}`,
    })
      .fetch("GET", url, headers)
      .progress(() => {
        setIsLoading((prev) => [...prev, file.id]);
      })
      .then(() => {
        changeDownloadState(file.id);
      })
      .catch(() => {
        changeDownloadState(file.id, false);
      })
      .finally(() => setIsLoading((prev) => prev.filter((item) => item !== file.id)));
  };

i have function in my react native project for downloading files. downloading on android emulator works perfect. but I don’t see downloaded files on ios emulator. how can i fix it?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img