react-native-fs
react-native-fs copied to clipboard
Expo + react-native-fs
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?
-
npm install react-native-fs
-
react-native link react-native-fs
It seems that expo ignores "linked" modules to react-native.
Checkout expo's FileSystem module to use file system related functionality using expo Go.
Hey man React-Native-FS is not supported with Expo but it is only supported by Pure React Native
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.
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?
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!
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
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.
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.
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.
but by using expo we can not record audio in WAV or mp3 file. is there any solution for that in Expo ??
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.
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
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.
I used the example in this comment and it worked just fine!
Apparently, Expo Media Library can't handle PDF files
That is right man why the hell they have created this expo in first place if it does not support to mobile device storage
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