Questions tagged [react-native-fs]

165 questions
32
votes
5 answers

How to download a file with React Native?

I am building an app with React Native, for Android and iOS. I am trying to let the user download a PDF file when clicking on a button. react-native-file-download does not support Android react-native-fs does nothing when I trigger downloadFile…
Arnaud
  • 3,793
  • 13
  • 45
  • 80
12
votes
3 answers

How to save pdf to android file system and then view PDF - react-native

I am using the react-native-fs and I am trying to save a base64 of a pdf file to my android emulators file system. I receive base64 encoded pdf from the server. I then decode the base64 string with the line: var pdfBase64 =…
Larney
  • 1,436
  • 3
  • 18
  • 44
11
votes
1 answer

RNFS.exists() always returns TRUE

I am using react-native-fs and for some reason whenever I use the exists() method it is always returning as TRUE. A sample of my code looks like this: let path_name = RNFS.DocumentDirectoryPath + "/userdata/settings.json"; if…
kojow7
  • 7,165
  • 11
  • 60
  • 109
7
votes
2 answers

How to calculate checksum in React Native and Node?

I'm uploading an image file from React Native to AWS Lambda (Node 10.x) and want to verify the hash of the file I've sent matches the file received. To do this I'm using hashing in React Native and again in Lambda, but the hashes never match. Here…
Fook
  • 4,220
  • 5
  • 25
  • 45
7
votes
1 answer

Open a file (pdf, word, excel, png etc.) on device with its default application in react-native

I'm using react-native-fs to download a file(pdf, word, excel, png etc.) and I need to open it in other application. Is it possible to open downloaded file with Linking or better open a dialog with possible apps like when using Sharing? Linking in…
7
votes
2 answers

React-native-android - How to save an image to the Android file system and view in the phone's 'Gallery'

Is it possible to save an image to the android's local file system so it can be viewed from the phone's 'Gallery' and in a folder?? I found this react-native-fs library but after studying the documentation and working through an example I am still…
5
votes
2 answers

Get file from react-native to upload image same as ` `

I have tried doing var photo = { uri: uriFromCameraRoll, type: 'image/jpeg', name: 'photo.jpg', }; and using axios var body = new FormData(); body.append('authToken', 'secret'); body.append('photo', photo); body.append('title', 'A…
5
votes
1 answer

react native fs library not writing files

when i use react-native-fs to create file, success in callback arrives but the file isn't in my android/data/com.myapp/files/test.txt library. No errors in logcat so i'm wondering why my code with simple App.js not working. /** * Sample React…
Vojtěch Prchal
  • 141
  • 2
  • 11
5
votes
1 answer

React-Native method hangs and does not throw an error

I am using the react-native-fs module, however my app seems to be freezing on it. I have the following piece of code in one of my React-Native methods: console.log("One") await RNFS.downloadFile({ fromUrl: 'http://example.com/data/blah.zip', …
kojow7
  • 7,165
  • 11
  • 60
  • 109
5
votes
2 answers

Move file from tmp to documents using react-native-fs

I'm trying to move a file selected from a document picker to the Document Directory using react-native-fs and react-native-document picker. However, I get the error below: Error: “file name.mp3” couldn’t be moved to “Documents” because either the…
liver
  • 528
  • 4
  • 19
5
votes
1 answer

Attempting to add an openFile method to React Native, can't call getCurrentActivity

Inside a fork of react-native-fs ( https://github.com/johanneslumpe/react-native-fs ), I'm attempting to add this code: public class RNFSManager extends ReactContextBaseJavaModule { public RNFSManager(ReactApplicationContext reactContext) { …
freyley
  • 3,385
  • 3
  • 17
  • 24
4
votes
1 answer

EISDIR: illegal operation on a directory, read in React Native file system

I'm trying simple code to copy a file to another external folder using this code: RNFS.copyFile(sourcePath, destinationPath) .then(result => { console.log('file copied:', result); }) .catch(err => { console.log('error: ', err.message,…
4
votes
1 answer

React native fs iOS not showing files in the document directory

I am working on a react native project. I need to store the captured images in the custom folder. I am using react native fs library for that. I am able to create the image in the desired directory but I am not able to see those images in my…
Pankaj Agrawal
  • 1,033
  • 1
  • 13
  • 22
4
votes
2 answers

Read local asset in react-native-fs

I have a file ("static.zip") in the root directory of my react-native project that I'm trying to access it via the react-native-fs library. Given this example, I thought it would be as easy as this on iOS: sourcePath =…
tassock
  • 1,565
  • 1
  • 14
  • 30
4
votes
1 answer

Try to use react-native-fs in create-react-native-app project (expo)

I'm trying to use react-native-fs in my app to upload files etc. I followed the installation like the documentation, make the import and i'd put this code for the test : componentDidMount(){ const path = RNFS.DocumentDirectoryPath +…
E.D
  • 309
  • 4
  • 17
1
2 3
10 11