'Cant download on iOS with expo-file-system

Im trying to download using Expo-File-System on an expo project with react native.

The download option works on Expo-Go during testing but wont work when i push it in production mode.

It says that it is "unable to save file in the local URI because you dont have Document Permissions" as shown in the Picture below.

Here is the code (Using typescript):

import * as MediaLibrary from 'expo-media-library';

///For downloading the file
  const download = async (item: ICurriculumCourseDocument) => {
    setIsloading(true)

    await FileSystem.downloadAsync(
      `https:/baseUrl`,
      FileSystem.documentDirectory + item.filename,
      options
    )
      .then(({ uri }) => {
        setIsloading(false)
        console.log('Finished downloading to', uri);
        onShareIOS(uri)
      })
      .catch(error => {
        setIsloading(false)
        alert(error);
      });
  }


//For sharing the file using the Share
  const onShareIOS = async (uri: string) => {
    const imageFileExts = ['jpg', 'png', 'gif', 'heic', 'webp', 'bmp'];

    if (imageFileExts.every(x => !uri.endsWith(x))) {
      const UTI = 'public.item';
      await Sharing.shareAsync(uri, {UTI});
    }  
  };

Here is the full Alert with the error message: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source