nativescript-community / ui-document-picker

A NativeScript plugin that allows you to select files from the device.
https://nativescript-community.github.io/ui-document-picker/
Apache License 2.0
10 stars 8 forks source link

Android picker returns null if a file is selected from Recent section #13

Open shiv19 opened 2 years ago

shiv19 commented 2 years ago

image If I select the XML file from the Recent section then I get back null,

JS: {
JS:   "files": [
JS:     null
JS:   ],
JS:   "android": {}
JS: }

However, if I open the menu and go into the internal storage, downloads and then select the file, I get the correct path

JS: {
JS:   "files": [
JS:     "/storage/emulated/0/Download/NectronGoldenAle.xml"
JS:   ],
JS:   "android": {}
JS: }
farfromrefug commented 2 years ago

@shiv19 that seem native related. Did you try on real device?

shiv19 commented 2 years ago

@farfromrefug yes, these screenshots are from a real device. It was connected to my laptop via USB debugging mode.

shiv19 commented 2 years ago

The target SDK is 30.

ShimonKh commented 2 years ago

I'm also having the same problem, does anyone have a solution?

dfborba commented 2 years ago

Same here. Seems that the error is not only related to recent section, because it had occasions which I was able to navigate to a folder and back to recent section and I was able to pick file. In other times it return null from Download section.

farfromrefug commented 2 years ago

@dfborba @ShimonKh sorry i dont have much time to look at this right now. The best thing would be to make a quick search on the web to see if it happens with native. We could find a solution on stackoverflow.

dfborba commented 2 years ago

@farfromrefug Don't worry, I definitely understand :). The solutions I've found didn't work for my case, but I'll keep searching!
If you have any EAT in the further future, please tell us, it would be great to have all in one place instead of a lot of logic outside the plugin.

OPADA-Eng commented 2 years ago

Same for me, any solution or workaround?

xpalacincreditoh commented 2 years ago

I have the same error when select a PDF or doc file with Android 11 SDK 30.

And in my case when attempt to read file get error: Error: ReadTask returns no result.

const file = fileSystemModule.File.fromPath(results[0]);
                    console.log('file', file);
                    const name = file._name;
                    console.log('name', name);
                    let filebase64 = '';

                    file.read().then((value) => {
                        console.log('value', value);
                        if (isAndroid) filebase64 = android.util.Base64.encodeToString(value, android.util.Base64.NO_WRAP);
                        else filebase64 = value.base64EncodedStringWithOptions(0);
                        accept([
                            {
                                file: filebase64,
                                name: name,
                            },
                        ]);
                    }).catch(function (e) {
                        // process error
                        console.log('file.read error');
                        console.log(e);
                        reject('Algo ha fallado al subir la imagen desde la galería, inténtelo de nuevo.');
                    });

If i change to targetSdkVersion 29 works fine but to publish now to google app store need 30