question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I had a number of issues with the implementation of this library, enough that I ditched it and started working on my own document picker implementation internally to fit my needs.

I’d be willing to instead help overhaul this library if the community and package owner are willing to accept the changes I want to make.

  • iOS idea: The hfsTypeCode should be used to attempt to return a mime type. (hfsTypeCode doesn’t seem to return anything) Use Apple’s UTI handling to implicitly get a mime type from a file extension.
  • iOS bug: A callback should be called with an error instead of exiting and never responding.
  • iOS bug: Migrate from the deprecated UIDocumentMenuViewController to UIDocumentPickerViewController.
  • Android: ACTION_PICK should never be used, it is intended for choosing data from a media provider, not choosing any document of a mime type.
  • Android: ACTION_GET_CONTENT should be used by default instead of ACTION_OPEN_DOCUMENT to match the intent of the iOS behavior: iOS declares the mode as import rather than open, which matches the semantics of ACTION_GET_CONTENT (just reading/importing data) rather than ACTION_OPEN_DOCUMENT (long term persistent access to a document/editing of it).
    • Optional: We could provide an option to allow the user to choose between import/get_content mode and persistent open mode. Maybe a mode, forOpen: true, or persistent option.
  • Android: Intent handler should guard against nonexistent current activity and failure to show the document picker due to a throw.
  • Support multiple document selection: Do this with a second method that always returns a promise for an array to keep the possibility of supporting flow types (rename show -> pick and add pickMultiple). I already have code for this on Android. On iOS support for this is coming in iOS 11.
  • Return a Promise instead of using a callback: RN’s native documentation recommends using promises for async js/native handling instead of callbacks (callbacks to native on iOS are marked as experimental). And almost all of react-navigation’s own public APIs now use Promises instead of callbacks.
  • Errors returned by the library should include a string error code that makes it possible to identify the error.
  • Add a .isCancel(err) method to check if an error is due to the user canceling the document picking and actually bother to check for Activity.RESULT_CANCELED.
  • filetype is poorly named, refactor this to just type.
  • Android: A document picker should not implicitly download a file if it gets a network URL.
  • Android: Use getInt(sizeIndex) to get the file size, it should not be converted to a string and than parsed back into an int.
  • Android: Drop all file path and http handling from the document picker. Both ACTION_GET_CONTENT and ACTION_OPEN_DOCUMENT explicitly state that the URI returned by the intent must be a content: URI that can be used with a content provider.
  • Android: Update content resolver handler to use DocumentsContract.Document.COLUMN_MIME_TYPE on KitKat+ instead of just getType to get the mime type.
  • Change fileName to name: The DISPLAY_NAME on Android is not guaranteed to be a file name.
  • DocumentPickerUtil should use Platform.OS === 'ios' instead of Platform.OS === 'android'.
  • Default to an */*/allFiles when type is not defined.
  • Cleanup the public API: DocumentPicker should be the default export. And types selection should not be named “*Util” or require a verbose extra import. I recommend DocumentPicker.types.images. The function invocation can safely be dropped while still avoiding {type: DocumentPicker.types.somethingThatDoesNotExist} bugs and supporting “allFiles by default” by checking for types that are undefined but are present (ie: 'type' in opts is true but opts.type === undefined) and a similar test for arrays.
  • Android: Rename DocumentPicker.java to DocumentPickerModule.java and ReactNativeDocumentPicker.java to DocumentPickerPackage.java.
  • com.reactnativedocumentpicker is a poor namespace name that’s a reverse domain that this project does not own, refactor the library to use a github repo based namespace.
  • Add a warning when native code is not available
  • Make sure a chooser is used on Android API level 18 where the new DocumentProvider picker is not available
  • #50 Fix make type option with more than 1 types work on Android

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:27
  • Comments:54 (19 by maintainers)

github_iconTop GitHub Comments

4reactions
armanatzcommented, Dec 12, 2017

Any news on v3 @Elyx0 @dantman?

3reactions
Elyx0commented, Jul 4, 2019

I merged V3 into master, let’s address all the new bugs PR into master now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 6101: The Secure Sockets Layer (SSL) Protocol Version ...
RFC 6101 The SSL Protocol Version 3.0 August 2011 Status of This Memo This document is not an Internet Standards Track specification; it...
Read more >
RFC Series Residential Concealed Pendent Sprinklers
RFC Series Residential Concealed Pendent Sprinklers · Style List: Pendent · K Factor: 3.0 (43), 4.3 (62), 4.9 (71), 5.8 (84), 7.6 (109) ......
Read more >
[RFC] Discussion about 3.0.0 breaking changes · Issue #3940 - GitHub
This issue serves as a forum that allows people from throughout the community to discuss what changes they would like to see. I...
Read more >
RFC: proposals for zend-db 3.0.0 - Contributors - Laminas Project ...
We are working on some PRs and we plan to have a 2.10 release very soon. We would like also to plan a...
Read more >
SAP Connector for Microsoft .NET 3.0
NET application (inside-out). You can also access .NET components from any ABAP application by implementing an RFC server in .NET (outside-in).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found