Git Product home page Git Product logo

react-native-file-selector's Introduction

PRs Welcome

ReactNative: Native File Selector (Android/iOS)

If this project has helped you out, please support us with a star 🌟

This library is a ReactNative Bridge around native libraries. It allows you to natively select/pick file from device file system:

Android: nbsp-team/MaterialFilePicker/

Note: It allows you to pick file without using Intent/Third Party Software

iOS: marmelroy/FileBrowser

Note: It allows you to select only local files associate to app sandbox.

📖 Getting started

$ npm install react-native-file-selector --save

This library is supports RN60 and above

  • iOS

iOS Prerequisite: Please make sure CocoaPods is installed on your system

- Add the following to your `Podfile` -> `ios/Podfile` and run pod update:
  use_native_modules!

  pod 'RNFileSelector', :path => '../node_modules/react-native-file-selector/ios'

  use_frameworks! :linkage => :static

  pod 'FileBrowser', :git => 'https://github.com/prscX/FileBrowser'

  # Follow [Flipper iOS Setup Guidelines](https://fbflipper.com/docs/getting-started/ios-native)
  # This is required because iOSPhotoEditor is implemented using Swift and we have to use use_frameworks! in Podfile
  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
    'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']
  
  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
  end
  • Please make sure Flipper iOS Setup Guidelines steps are added to Podfile, since iOSPhotoEditor is implemented using Swift and we have to use use_frameworks! in Podfile

  • Android

  • Add below color attributes in your app's android/app/src/main/res/values/color.xml file. You can provide your own color codes.

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="colorPrimary">#3F51B5</color>
        <color name="colorPrimaryDark">#303F9F</color>
        <color name="colorAccent">#FF4081</color>
    </resources>

💻 Usage

import RNFileSelector from 'react-native-file-selector';

  • API Way
RNFileSelector.Show(
    {
        title: 'Select File',
        onDone: (path) => {
            console.log('file selected: ' + path)
        },
        onCancel: () => {
            console.log('cancelled')
        }
    }
)
  • React Way
<RNFileSelector title={"Select File"} visible={this.state.visible} onDone={() => {
    console.log("file selected: " + path);
}} onCancel={() => {
    console.log("cancelled");
}}/>

💡 Props

Prop Type Default Note
title string Title on the toolbar
closeMenu string true Color of tint
hiddenFiles: Android bool false If true it shows hidden files as well
path string Path of directory
filter string Filter to sort the files
filterDirectories: Android bool Filter should be applied on directories or not
onDone func Function called when file is selected
onCancel func Function called when file selector is closed without selecting any file
visible bool false To invoke file selector

Note

  • Filter
    • Android: Please find regex/Pattern for defining filter
    • iOS: Array of file extension needs to be ignore

✨ Credits

🤔 How to contribute

Have an idea? Found a bug? Please raise to ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list below. ✨

📜 License

This library is provided under the Apache License.

RNFileSelector @ prscX

💖 Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀

  • If you're feeling especially charitable, please follow prscX on GitHub.

    Buy Me A Coffee

    Thanks! ❤️
    prscX.github.io
    </ Pranav >

react-native-file-selector's People

Contributors

prscms avatar prscx avatar vieiralucas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-file-selector's Issues

FilePickerActivity cannot start

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.newrouter/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.RuntimeException: Failed to resolve attribute at index 1362
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$800(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 1362

iOS 12 compatibility error

Just upgraded to Xcode 10.0 and get the following error:

dyld: Symbol not found: __T0BOWV
Referenced from: /private/var/containers/Bundle/Application/FE262A78-23EA-4235-87EF-6FBDE57A7457/LinkReactNative.app/Frameworks/FileBrowser.framework/FileBrowser
Expected in: /private/var/containers/Bundle/Application/FE262A78-23EA-4235-87EF-6FBDE57A7457/LinkReactNative.app/Frameworks/libswiftCore.dylib
in /private/var/containers/Bundle/Application/FE262A78-23EA-4235-87EF-6FBDE57A7457/LinkReactNative.app/Frameworks/FileBrowser.framework/FileBrowser

File Selector not working on ios. null is not an object(evaluating RNFileSelector.Show)

I did everything that was prescribed in Readme but no success.
This is my PODFILE:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'project' do
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'Firebase/Core', '> 6.3.0'
pod 'Firebase/Messaging', '
> 6.3.0'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
pod 'React-RCTCameraRoll', :path => '../node_modules/react-native/Libraries/CameraRoll'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'react-native-document-picker', :path => '../node_modules/react-native-document-picker'
pod 'RNFS', :path => '../node_modules/react-native-fs'

pod 'RNAudioRecorderPlayer', :path => '../node_modules/react-native-audio-recorder-player'

pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'

pod 'react-native-background-downloader', :path => '../node_modules/react-native-background-downloader'

pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'

use_native_modules!

pod 'RNFileSelector', :path => '../node_modules/react-native-file-selector/ios'

use_frameworks!

pod 'FileBrowser', :git => 'https://github.com/prscX/FileBrowser'

target 'projectTests' do
inherit! :search_paths
end

end

target 'project-tvOS' do

target 'project-tvOSTests' do
inherit! :search_paths
end

end

App crash with RN 0.61.x. (Android)

App crashed where open file selector. RN version is 0.61.5. Platform is Android

"dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-file-selector": "^1.0.0"
  },
import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
import RNFileSelector from 'react-native-file-selector';
export class App extends Component {
  openFile = () => {
    RNFileSelector.Show({
      title: 'Select File',
      onDone: path => {
        console.log('file selected: ' + path);
      },
      onCancel: () => {
        console.log('cancelled');
      },
    });
  };

  render() {
    return (
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <TouchableOpacity onPress={this.openFile}>
          <Text> open file selector </Text>
        </TouchableOpacity>
      </View>
    );
  }
}

export default App;

FilePicker is not shown up inside modal

"react-native": "0.54.4",
"react-native-file-selector": "0.0.6",
"react-native-modal": "^6.0.0",

file-selector doesn't open up when modal is open.
Does anyone has similar issue?

FileBrowser.Framework

Hello, I have install and link this package, but i didn't see FileBrowser.Framework.

crash app in Android

Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f040070 a=2 r=0x7f06002c}

Cant get all details of file

I want fileName, fileSize, fileType also along with file path .If it can be done let me know else it should be included in library.

Could not resolve all files for configuration ':app:debugCompileClasspath'

E:\Projects\APP\YDJW>react-native --version
react-native-cli: 2.0.1
react-native: 0.59.1

Task :app:preDebugBuild FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all files for configuration ':app:debugCompileClasspath'.

Could not find com.nbsp:library:1.8.
Required by:
project :app > project :react-native-file-selector

when I install this lib and link this, I can not open my app

I got an error

dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Users/apple/Library/Developer/Xcode/DerivedData/SaletApp-btvptihtfeciokdhrsxvmygljebg/Build/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser
Reason: image not found
(lldb)

please help me how to resolve my issue, thank u

image not found

dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Users/***/Library/Developer/Xcode/DerivedData/APPName-ciohvchhwvwbfubwetjezrhgxcbs/Build/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser
Reason: image not found

New release

Can you make a release to npm? I need the fix from #19 and don't want to point my package.json to master.
Thanks

iOS thread 1 signal sigabrt

I have followed instructions how to setup for iOS, but I keep getting thread 1 signal sigabrt in main.m.
Screenshot from 2019-07-09 16-07-02

When I comment out part in AppDelegate.m...
Screenshot from 2019-07-09 16-27-21

It passes, so have I put that part in wrong place, since I was not sure from instruction where to put it in code...
Or maybe something else is problem?

没有找到 "Build Settings -> Frameworks Search Path"

Go to your project's Build Settings -> Frameworks Search Path and add ${BUILT_PRODUCTS_DIR}/FileBrowser non-recursive.

当我进行到这个步骤时,我在自己的项目下点击Build Settings卡片,但我没有找到Frameworks Search Path这项,所以无法再进行下去
图片

[Android] Permission is asked behind the selection view

Environment

  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
      Memory: 1.01 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 17, 21, 23, 25, 26, 27
        Build Tools: 23.0.1, 23.0.3, 24.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.2, 28.0.3
        System Images: android-25 | Google APIs Intel x86 Atom_64
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.57.8 => 0.57.8
    "lodash": "^4.17.11",
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-file-selector": "^0.0.6",

Description

When I make the RNFileSelector appear for the first time the permission is asked to access the files but the pop-up is located under the file selector which show an empty list cause we don't have access till the user gives the permission. So after closing the view we can accept and then go to the list now full

Reproducible Demo

Just have a button that show (turn visible to true) and this code

      <RNFileSelector
        title="Select File"
        visible
        onDone={(url) => {
          this.setState({
            visible: false,
          });
        }}
        onCancel={() => {
          console.log('cancelled');
          this.setState({
            visible: false,
          });
        }}

Thanks a lot

ios integration failed

react-native 0.59.9
Is there a more detailed explanation ?
Screenshot or other ?
Hope to get your answer.

Could not find auto-linked framework 'FileBrowser'

Hello. The error is shown when I try to build the project in xCode. What can be the issue?

ld: warning: Could not find auto-linked framework 'FileBrowser'
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$__TtC11FileBrowser11FileBrowser", referenced from:
  objc-class-ref in libRNFileSelector.a(RNFileSelector.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error while generating the main dex list

I was not able to install at first after installing and linking the library. Then I added below maven dependency.

maven {
	url  "http://dl.bintray.com/lukaville/maven" 
}

Now it is showing below Error:

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the
 main dex list.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 43s
421 actionable tasks: 399 executed, 22 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

I have also enabled multiDexEnabled true in build.gradle but still stuck at same error. Please help me installing it.

Thanks in advance.

iOS-RNFileSelector not showup as expected

There is a log raised up said:

Warning: Attempt to present <FileBrowser.FileBrowser: 0x1038da000> on <UINavigationController: 0x10382ec00> which is already presenting <RCTModalHostViewController: 0x1027f1ea0>

Maybe I miss some step in install?

Folder selector

Can I use this for folder selector? I want to save file to a specific folder selected by user.

android in webview Select file image upload crash(solved) java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, dat

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, dat

找到node_modules/react-native-file-selector/android/src/main/java/ui/fileselector/RNFileSelectorModule.java

修改
`public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {

  if (requestCode == 1 && resultCode == AppCompatActivity.RESULT_OK) {
    String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
    if(filePath == null){
      return;
    }else{
      onDone.invoke(filePath);
    }
  } else if (requestCode == 1 && resultCode == AppCompatActivity.RESULT_CANCELED) {
    if(onCancel != null){
      onCancel.invoke();
    }
  }
}`

Undefined is not an object RNFileSelector.Show

Hi,

I have installed the library using "npm install react-native-file-selector --save"

In android/app/build.gradle I have added the below lines

repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://maven.google.com" }
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://maven.google.com" }
}
}

I have imported import RNFileSelector from 'react-native-file-selector'; in js file

on click of button calling

RNFileSelector.Show(
{
title: 'Select File',
onDone: (path) => {
console.log('file selected: ' + path)
},
onCancel: () => {
console.log('cancelled')
}
}
);

I am getting "undefined is not an object RNFileSeector.Show"

Am I doing anything wrong?

does react-native-file-selector require actual account?

I am working on Xcode as Personal Team. Now i need to use file selector but first i want to know do i need to have actual account for developer program and signing certificates?
As in Linked framework and Libraries, "libRNFileSelector.a" is not in listing to add with home icon.

image

The following error occurred while running the iOS project

node_modules/react-native-file-selector/ios/Pods/Target Support Files/Pods-RNFileSelector/Pods-RNFileSelector.debug.xcconfig: unable to open file (in target "RNFileSelector" in project "RNFileSelector") (in target 'RNFileSelector')

I just can't get files listed

Hello there, how you doing?

I managed to get this package running on my RN app but unfortunately I can't get a single file listed, I'm using the default snippet:

RNFileSelector.Show({
  title: 'Select File',
  onDone: path => {
    alert(path);
  },
  onCancel: () => null,
});

Once I press the button, I get to this screen:
img_0051

I'm not an iOS user so I don't know how to create a file under documents either :D

iOS Error: Cant find Pods.xcodeproject and can't able to pod install too

Hi,

When I try to install pod, getting this error.

`Downloading dependencies
Installing FileBrowser (1.0.0)
[!] Unable to determine Swift version for the following pods:

  • FileBrowser does not specify a Swift version and none of the targets (RNFileSelector) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

[!] The Podfile contains framework or static library targets (RNFileSelector), for which the Podfile does not contain host targets (targets which embed the framework).
If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).`

RNN with React Native File Selector

Hey @prscX, thank you for your awesome work.

I am using React-Native-Navigation (v1) in my current project. Based on their installation instructions, changes have been made to AppDelegate.m file. Now It looks like:

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>

// **********************************************
// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
// **********************************************
#import "RCCManager.h"

// IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
// with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)

#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>

#import <Firebase.h>
#import <BugsnagReactNative/BugsnagReactNative.h>

@implementation AppDelegate
  
  
  //deeplink
  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
  {
    return [RCTLinkingManager application:application openURL:url
                        sourceApplication:sourceApplication annotation:annotation];
  }
  
  // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html).
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
  {
    return [RCTLinkingManager application:application
                     continueUserActivity:userActivity
                       restorationHandler:restorationHandler];
  }
  //end deeplink

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;
#ifdef DEBUG
  //  jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios&dev=true"];
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
  
  [FIRApp configure];
  [BugsnagReactNative start];
  
  // **********************************************
  // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
  // **********************************************
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];
  
  /*
   // original RN bootstrap - remove this part
   RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
   moduleName:@"example"
   initialProperties:nil
   launchOptions:launchOptions];
   self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
   UIViewController *rootViewController = [UIViewController new];
   rootViewController.view = rootView;
   self.window.rootViewController = rootViewController;
   [self.window makeKeyAndVisible];
   */
  
  
  return YES;
}

@end

So far with your installation instructions I've reached the point where I need to paste a specific code in the same file to handle the navigation. Specifically, this part that allows to open the file selector view:

  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
  navigationController.navigationBar.hidden = YES;

  self.window.rootViewController = navigationController;

//  self.window.rootViewController = rootViewController;

Unfortunately it doesn't seem compatible anymore, since native RN initialization is overwritten. Any input on how to tackle with this scenario will be appreciated.
Thanks.

[!] Unable to determine Swift version for the following pods:

[!] Unable to determine Swift version for the following pods:

  • FileBrowser does not specify a Swift version and none of the targets (RNFileSelector) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

Build Failed

Hi there,
I'm very new to React Native and I'm facing some issues in installing this lib.
I have installed the library and then linked it.
After running the command react-native run-android, I am getting this error :

image

Please help me to resolve it.
Thanks in advance.

onCancel never gets called for iOS

The callback onCancel never gets called. I have followed the instruction on README for iOS, everything was working fine except the onCancel never gets called. I looked into the source code and I think onCancel is passed down to /react-native-file-selector/ios/RNFileSelector.m and it seem like that onCancel is never used. But I am not 100% sure since I have knowledge for swift or objective C.

pod install

when i add 'use_frameworks!' into the podfile
it will happen ' statically linked binaries ' i'm a new in ios ,sorry

compile update to implementation

please update react-native-file-selector/android/build.gradle

dependencies {
compile 'com.nbsp:library:1.8'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.facebook.react:react-native:+'
}
to

dependencies {
implementation 'com.nbsp:library:1.8'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.facebook.react:react-native:+'
}

thanks !!!!!

Could you please tell me what is it? what happened to that android phone?

微信图片_20190904204021

I don't know why would it happen, this is my code:

**
<RNFileSelector title="title" visible={this.state.visible} onDone={() => {
console.log("file selected: " + path);
}} onCancel={() => {
console.log("cancelled");
}}/>
**

just followed as what README.md told me, and this question happened from Android 5.1/6/9

start the app, show me this error

10-09 17:07:19.277 6040-6040/com.newrouter E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.newrouter, PID: 6040
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.newrouter/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.RuntimeException: Failed to resolve attribute at index 1362
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$800(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 1362
at android.content.res.TypedArray.getColor(TypedArray.java:401)
at android.app.Activity.onApplyThemeResource(Activity.java:3683)
at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java:140)
at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java:85)
at android.support.v7.app.AppCompatActivity.setTheme(AppCompatActivity.java:89)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2273)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392) 
at android.app.ActivityThread.access$800(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5293) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

Problem with installation

Hi @prscX ,

I'm trying to install the module.
But I'm having some problems.
I created the file res / values / color.xml

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

repositories {
    maven {
        url  "http://dl.bintray.com/lukaville/maven"
    }
    maven { url "https://maven.google.com" }
}

repositories {
    maven {
        url  "http://dl.bintray.com/lukaville/maven"
    }
    maven { url "https://maven.google.com" }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.playervideo"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

repositories {
    maven {
        url  "http://dl.bintray.com/lukaville/maven"
    }
    maven { url "https://maven.google.com" }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://maven.google.com" }
    }
}

dependencies {
    compile project(':react-native-file-selector')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

log

JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-file-selector 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.design.widget.CoordinatorLayout$Behavior


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder
\debug\119.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\120.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\i
ntermediates\transforms\dexBuilder\debug\121.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\122.jar, C:\Users\pc\Desktop\m
mm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\123.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug
\124.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\125.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\interme
diates\transforms\dexBuilder\debug\126.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\127.jar, C:\Users\pc\Desktop\mmm\pla
yervideo\android\app\build\intermediates\transforms\dexBuilder\debug\128.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\129.j
ar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\130.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates
\transforms\dexBuilder\debug\131.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\132.jar, C:\Users\pc\Desktop\mmm\playervid
eo\android\app\build\intermediates\transforms\dexBuilder\debug\133.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\134.jar, C:
\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\135.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\trans
forms\dexBuilder\debug\136.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\137.jar, C:\Users\pc\Desktop\mmm\playervideo\and
roid\app\build\intermediates\transforms\dexBuilder\debug\138.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\139.jar, C:\Users
\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\140.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\
dexBuilder\debug\141.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\142.jar, C:\Users\pc\Desktop\mmm\playervideo\android\a
pp\build\intermediates\transforms\dexBuilder\debug\143.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\144.jar, C:\Users\pc
\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\145.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBui
lder\debug\146.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\147.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\bui
ld\intermediates\transforms\dexBuilder\debug\148.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\152.jar, C:\Users\pc\Deskt
op\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\156.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\d
ebug\160.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\164.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\int
ermediates\transforms\dexBuilder\debug\168.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\172.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s
36 actionable tasks: 1 executed, 35 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Return path?

Nice package btw, but is this package only return path of selected file?
How to return string value if I select text file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.