TLDR;
I have a react-native mobile application which needs to receive a file shared by ther other application.
Details:
I am trying to receive this file inside my own application. And since I am new to React/React-native/Expo/Android development I am not sure how it’s coded in react native.
- connect the mobile device to phone and allow development and tethering. or have emulator ready
Mobile App:
run following commands in the terminal:
git clone https://github.com/dimaportenko/react-native-receive-share-file-tutorial
run yarn install
run yarn android
Browser:
-
In broswer of the mobile phone navigate to https://w3c.github.io/web-share/demos/share-files.html
-
Fill Data.
-
Attach a file.
-
click ‘Share’
-
Select the ‘rnrecievesharetutorial’
-
This should show something like following
Received Files Array [
Object {
"contentUri": null,
"extension": null,
"fileName": null,
"filePath": null,
"subject": "Credential Offer",
"text": "Choose a wallet to process this offer.",
"weblink": null,
},
]
Question:
Can you please share some code which allows me to get the file data ?
The website has indeed shared the file data. As a proof: if you select the email/gmail application on your phone it should add the file as an attachement.
2
Answers
I was not receiving the Location of the local file. I used another lib: https://github.com/meedan/react-native-share-menu. I receive the Location of the file. And then we can use file read/write libs to get the content.
You can download data using RNFS
you can access the file as