[RFC] 3.0.0
See original GitHub issueI 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:
TheUse Apple’s UTI handling to implicitly get a mime type from a file extension.hfsTypeCode
should be used to attempt to return a mime type. (hfsTypeCode doesn’t seem to return anything) - iOS bug: A callback should be called with an error instead of exiting and never responding.
- iOS bug: Migrate from the deprecated
UIDocumentMenuViewController
toUIDocumentPickerViewController
. - 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 ofACTION_OPEN_DOCUMENT
to match the intent of the iOS behavior: iOS declares the mode asimport
rather thanopen
, which matches the semantics ofACTION_GET_CONTENT
(just reading/importing data) rather thanACTION_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
, orpersistent
option.
- Optional: We could provide an option to allow the user to choose between import/get_content mode and persistent open mode. Maybe a
- 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 addpickMultiple
). 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 forActivity.RESULT_CANCELED
. -
filetype
is poorly named, refactor this to justtype
. - 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
andACTION_OPEN_DOCUMENT
explicitly state that the URI returned by the intent must be acontent:
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 justgetType
to get the mime type. - Change
fileName
toname
: The DISPLAY_NAME on Android is not guaranteed to be a file name. -
DocumentPickerUtil
should usePlatform.OS === 'ios'
instead ofPlatform.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 recommendDocumentPicker.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 butopts.type === undefined
) and a similar test for arrays. - Android: Rename
DocumentPicker.java
toDocumentPickerModule.java
andReactNativeDocumentPicker.java
toDocumentPickerPackage.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:
- Created 6 years ago
- Reactions:27
- Comments:54 (19 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any news on v3 @Elyx0 @dantman?
I merged V3 into master, let’s address all the new bugs PR into master now 😃