react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Expo + react-native-fs

Open sebastianbochan opened this issue 5 years ago • 16 comments

Description

In my application I am not able to run it with linked modules.

Expected Behavior

React native should link module.

Observed Behavior

I need to open files from local system. In npm, there is library like react-native-fs but still receive error.

undefined is not an object (evaluating 'RNFSManager.RNFSFileTypeRegular')

How to add module?

  1. npm install react-native-fs
  2. react-native link react-native-fs

It seems that expo ignores "linked" modules to react-native.

sebastianbochan avatar Jun 14 '19 14:06 sebastianbochan

Checkout expo's FileSystem module to use file system related functionality using expo Go.

jobpaardekooper avatar Jun 18 '19 19:06 jobpaardekooper

Hey man React-Native-FS is not supported with Expo but it is only supported by Pure React Native

kunduaditya avatar Dec 12 '21 01:12 kunduaditya

Hey man React-Native-FS is not supported with Expo but it is only supported by Pure React Native

Do you know of an alternate package that I could use? I need to create a copy of a local ios image so I can add to an s3 bucket, but I don't know how else to create a copy of the file.

tannyb28 avatar Jun 28 '22 17:06 tannyb28

Hey man React-Native-FS is not supported with Expo but it is only supported by Pure React Native

Do you know of an alternate package that I could use? I need to create a copy of a local ios image so I can add to an s3 bucket, but I don't know how else to create a copy of the file.

Any solution or any alternate package you came across?

danishsshaikh avatar Sep 20 '22 09:09 danishsshaikh

I don't know why people aren't seeing my fist comment on here (maybe because I linked the package on the expo repo and not their docs) but I will post it again because people keep coming back here. Expo has a package that offers filesystem support:

https://docs.expo.dev/versions/latest/sdk/filesystem/

Good luck!

jobpaardekooper avatar Sep 20 '22 16:09 jobpaardekooper

is there no way to access the data/project folder of the app in expo ? What i came to know is there is only FileSystem.documentDirectory and FileSystem.cacheDirectory available in expo-file-system to access my requirements in android are Download File change location of files upon download extract file to a specific folder read sqlite db file from the project folder

I cant use the documentDirectory or cacheDirectory as i cant access them, can't see the downloaded file in the either directories

mrazabinabid avatar Sep 27 '22 11:09 mrazabinabid

Seems like this should be possible with expo-file-system what exactly are you stuck on? Maybe post a small code snippet that isn't working.

jobpaardekooper avatar Sep 27 '22 15:09 jobpaardekooper

but expo audio does not support MP3 and WAV file formats so handing that we need to use react-native-fs. how do we use expo audio for MP3 file formats???

Seems like this should be possible with expo-file-system what exactly are you stuck on? Maybe post a small code snippet that isn't working.

harshdew02 avatar Oct 16 '23 20:10 harshdew02

As far as I know expo audio does definitely support WAV files because I have an app that is playing them using expo audio. I would also expect it to support MP3 files. Why would you need react-native-fs to handle those files? The AVPlaybackSource section in the expo-av docs includes some more info on the supported formats per platform.

Here is a code example code of how I am playing WAV files.

const sound = new Audio.Sound()

console.log("Loading audio file")
await sound.loadAsync({ uri: pathToAudio })
console.log("Audio file loaded", pathToAudio)
    
console.log('Playing Sound')
await Audio.setAudioModeAsync({
    allowsRecordingIOS: false,
    playsInSilentModeIOS: true,
    interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
    interruptionModeIOS: InterruptionModeIOS.DoNotMix,
    playThroughEarpieceAndroid: false,
    shouldDuckAndroid: false,
    staysActiveInBackground: false
})
await sound.playAsync()

Make sure the pathToAudio is correctly formatted starting with file:/// and make sure the file is actually at that location.

I don't think you need to set all of those options like I do at the end but I am providing it here so you can try it exactly like I have it. (which is working). And then after you confirm this is working you can adapt it it to work how you want it.

jobpaardekooper avatar Oct 16 '23 21:10 jobpaardekooper

but by using expo we can not record audio in WAV or mp3 file. is there any solution for that in Expo ??

harshdew02 avatar Oct 17 '23 08:10 harshdew02

I see...

You can record using MP3 (on iOS only) if that is something that helps. But probably not.

I think your best bet, if you must for some reason stick with expo go, is to upload the audio to a server and covert it there to the format you need.

jobpaardekooper avatar Oct 17 '23 09:10 jobpaardekooper

Expo File System doesn't support access to folders outside the app eg Android's Dowload folder. I need to save a PDF file in a directory that users can access trough their OS' file management system and Expo File System doesn't look like to support this

gabrielyotoo avatar Oct 25 '23 04:10 gabrielyotoo

That is interesting. Did not realize it was so hard to do something like that. I found a tutorial that might work for sharing the files outside of your apps directories.

jobpaardekooper avatar Oct 25 '23 08:10 jobpaardekooper

I used the example in this comment and it worked just fine!

Apparently, Expo Media Library can't handle PDF files

gabrielyotoo avatar Oct 30 '23 16:10 gabrielyotoo

That is right man why the hell they have created this expo in first place if it does not support to mobile device storage

jayprakash977 avatar Mar 21 '24 11:03 jayprakash977

I don't know why people aren't seeing my fist comment on here (maybe because I linked the package on the expo repo and not their docs) but I will post it again because people keep coming back here. Expo has a package that offers filesystem support:

https://docs.expo.dev/versions/latest/sdk/filesystem/

Good luck!

Man people are asking for functionality to write file and read file from mobile storage not get limited within app file system

jayprakash977 avatar Mar 21 '24 11:03 jayprakash977