itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.94k stars 975 forks source link

Expo + react-native-fs #688

Open sebastianbochan opened 5 years ago

sebastianbochan commented 5 years ago

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.

jobpaardekooper commented 5 years ago

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

kunduaditya commented 2 years ago

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

tannyb28 commented 2 years ago

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.

danishsshaikh commented 1 year ago

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?

jobpaardekooper commented 1 year ago

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!

mrazabinabid commented 1 year ago

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

jobpaardekooper commented 1 year ago

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 commented 11 months ago

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.

jobpaardekooper commented 11 months ago

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.

harshdew02 commented 11 months ago

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

jobpaardekooper commented 11 months ago

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.

gabrielyotoo commented 10 months ago

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

jobpaardekooper commented 10 months ago

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.

gabrielyotoo commented 10 months ago

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

Apparently, Expo Media Library can't handle PDF files

jayprakash977 commented 5 months ago

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 commented 5 months ago

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