0.2.3 • Published 1 year ago
react-native-file-open v0.2.3
react-native-file-opener
A React Native module that allows you to open a file (mp3, mp4, pdf, word, excel, dwg etc.) on your device with its default application
New add podspec, pod manager. No need to react-native link this file.
iOS | Android |
---|---|
Install
##iOS
1. npm install react-native-file-opener3 --save
No link need! podspec added yet.
- Compile and have fun
##Android
npm install react-native-file-opener3 --save
##Usage 1. In your React Native javascript code, bring in the native module
const FileOpener = require('react-native-file-opener3');
OR
import FileOpener from 'react-native-file-opener3';
- Basic usage
const FilePath = ...; // path of the file
const FileMimeType = ...; // mime type of the file
FileOpener.open(
FilePath,
FileMimeType
).then((msg) => {
console.log('success!!')
},() => {
console.log('error!!')
});
##Usage with react-native-fs
- You can get filepath by using react-native-fs
const RNFS = require('react-native-fs');
const FileOpener = require('react-native-file-opener3');
const SavePath = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath : RNFS.ExternalDirectoryPath;
const sampleDocFilePath = SavePath + '/sample.doc';
...
function openSampleDoc() {
FileOpener.open(
sampleDocFilePath,
'application/msword'
).then(() => {
console.log('success!!');
},(e) => {
console.log('error!!');
});
}
...
##Demo project https://github.com/huangzuizui/react-native-file-opener-demo
0.2.3
1 year ago
0.2.2
1 year ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.9
2 years ago
0.1.8
2 years ago
0.1.7
2 years ago
0.1.6
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago