READ_EXTERNAL_STORAGE permission exception html input type="file"

323 views
Skip to first unread message

jteam

unread,
Aug 29, 2015, 12:36:08 AM8/29/15
to phonegap
I'm using an HTML file selector, e.g.: <input type="file" id="id-image-upload-button" name="image-files[]" accept="image/*"/>

My app doesn't currently request any special permissions, and I'd like to keep it that way, but it seems that some uses try to select files on external storage and then cause this exception:

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/18239 from pid=21711, uid=10064 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1540)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:420)
at android.content.ContentResolver.query(ContentResolver.java:484)
at android.content.ContentResolver.query(ContentResolver.java:428)
at org.chromium.base.ContentUriUtils.getDisplayName(ContentUriUtils.java:134)
at org.chromium.android_webview.AwWebContentsDelegateAdapter$GetDisplayNameTask.resolveFileName(AwWebContentsDelegateAdapter.java:308)
at org.chromium.android_webview.AwWebContentsDelegateAdapter$GetDisplayNameTask.doInBackground(AwWebContentsDelegateAdapter.java:291)
at org.chromium.android_webview.AwWebContentsDelegateAdapter$GetDisplayNameTask.doInBackground(AwWebContentsDelegateAdapter.java:271)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more

This is from an Android 5.0 phone.

My app was build with PhoneGap Build 3.7, but I'm now updating to cli-5.2.0 (any chance this problem is fixed there?).

One solution would be add that permission - how?

Another solution would be for Cordova/PhoneGap to exclude files that the app doesn't have permission to read.  It feels like a bug that it doesn't exclude them.

Ideas?

Jesse Monroy

unread,
Aug 29, 2015, 2:10:17 AM8/29/15
to phonegap
@jteam,
several things.

1) this is not the support forum for Phonegap Build. Please see the homepage for this forum for that URL.
2) You are making some rather large assumptions. As such, I must assume you are new to Phonegap development
Please read:

Top Mistakes by Developers new to Cordova/Phonegap

https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/new-to-Phonegap.md
please read #1, #4, #8, #10 (and maybe #9)

3) For your issue you likely need to add the File Plugin:
Please read:

4) To reiterate, please go to the Phonegap Build forum for additional help. See the homepage for this forum.

TIA
Jesse

jteam

unread,
Aug 31, 2015, 10:46:17 AM8/31/15
to phonegap
Thanks Jesse - you're right - I meant to post this to the PhoneGap Build forum.
Reply all
Reply to author
Forward
0 new messages