React-native-document-picker: Picking a folder to save to

Created on 28 Jul 2016  路  6Comments  路  Source: rnmods/react-native-document-picker

Have you any idea if its possible to pick a folder to save to?

enhancement

Most helpful comment

I got the android stuff working on my fork, I'll send a PR when its all tested. It seems in android, if you open a document that you've picked using the Linking api then the OS gives you the ability to save it where you like, which is great. I'm wondering if there's an iOS equivalent, or if we could write one. Being able to save a document would be really helpful to me

All 6 comments

Not that I know of, I think the first "trip" goes to the temporary inbox no matter what, then you can move it from there. But on IOS there is no notion of "folders" where to save it

I got the android stuff working on my fork, I'll send a PR when its all tested. It seems in android, if you open a document that you've picked using the Linking api then the OS gives you the ability to save it where you like, which is great. I'm wondering if there's an iOS equivalent, or if we could write one. Being able to save a document would be really helpful to me

Can we clean this issue?

Just checking, you said you had it working on your fork. Is there a way to pick directories now?
I think this would be a completely different intent right? Like ACTION_OPEN_DOCUMENT_TREE
In fact I took a crack at it myself.

private static final int REQUEST_CODE_OPEN_DIRECTORY = 1;
@ReactMethod
public void pickDirectory(ReadableMap args, Promise promise) {
    Activity currentActivity = getCurrentActivity();

    if (currentActivity == null) {
        promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "Current activity does not exist");
        return;
    }

    this.promise = promise;

    try {
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
        currentActivity.startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY, Bundle.EMPTY);
    } catch (Exception e) {
        e.printStackTrace();
        this.promise.reject(E_FAILED_TO_SHOW_PICKER, e.getLocalizedMessage());
        this.promise = null;
    }
}

Also replace in onActivityResult
if (requestCode == READ_REQUEST_CODE || requestCode == REQUEST_CODE_OPEN_DIRECTORY)

From there the actual handing of the uri in onShowActivityResult will need to be rewritten instead of grabbing metadata....

Hello everyone 馃憢 we are talking about your issue here
And like I said in the other issue, I've made a fix for iOS but I'm waiting for a merge to finish the work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roadev picture roadev  路  3Comments

vsrinivas150283 picture vsrinivas150283  路  3Comments

obstruction6761 picture obstruction6761  路  6Comments

stsiushkevich picture stsiushkevich  路  7Comments

FrankFundel picture FrankFundel  路  5Comments