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

Error: java.io.FileNotFoundException: /storage/emulated/0/Download/helloworld.pdf: open failed: EACCES (Permission denied) #14

Closed meightythree closed 2 years ago

meightythree commented 2 years ago

Hey!

I would like to import file(s) from shared storage to my application's internal storage, however I got a permission denied error. I know this issue might not directly relate to this plugin, however I thought people here would know the solution and I might help others.

I have created a minimal reproduction of the issue, you can find it here: https://github.com/palikollar/ui-document-picker-demo

Given:

When:

Then:

I think the issue might been introduced in android API 30, when they added scoped storage a more restrictive permission handling for android.

JamesPoel commented 2 years ago

I also have this issue. Any updates?

farfromrefug commented 2 years ago

duplicate of https://github.com/nativescript-community/ui-document-picker/issues/7

meightythree commented 2 years ago

I have overcame this issue and you can use my solution: https://github.com/palikollar/ns-device-import-activity

I implemented my solution in Angular NS and it only works for android, I will probably keep using this package for ios.

I am using native Java to start the activity: https://github.com/palikollar/ns-device-import-activity/blob/master/App_Resources/Android/src/main/java/org/example/DeviceImportUtils.java

and I am waiting for the result here: https://github.com/palikollar/ns-device-import-activity/blob/master/src/app/activity.android.ts

You will still need to add some configuration and code, but please look through the commits for that.