[
https://issues.apache.org/jira/browse/CB-14097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16534219#comment-16534219
]
ASF GitHub Bot commented on CB-14097:
-------------------------------------
jcesarmobile closed pull request #322: CB-14097: (android) Fix crash when
selecting some files with getPicture
URL: https://github.com/apache/cordova-plugin-camera/pull/322
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/android/FileHelper.java b/src/android/FileHelper.java
index ccc5e3e7..edf16578 100644
--- a/src/android/FileHelper.java
+++ b/src/android/FileHelper.java
@@ -97,10 +97,21 @@ public static String
getRealPathFromURI_API11_And_Above(final Context context, f
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
- final Uri contentUri = ContentUris.withAppendedId(
- Uri.parse("content://downloads/public_downloads"),
Long.valueOf(id));
-
- return getDataColumn(context, contentUri, null, null);
+ if (id != null && id.length() > 0) {
+ if (id.startsWith("raw:")) {
+ return id.replaceFirst("raw:", "");
+ }
+ try {
+ final Uri contentUri = ContentUris.withAppendedId(
+
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
+
+ return getDataColumn(context, contentUri, null, null);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ } else {
+ return null;
+ }
}
// MediaProvider
else if (isMediaDocument(uri)) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Camera plugin crashes using getPicture on some files
> ----------------------------------------------------
>
> Key: CB-14097
> URL: https://issues.apache.org/jira/browse/CB-14097
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-camera
> Affects Versions: Master
> Environment: At least tested on:
> Cordova 7.1.0
> Camera 4.0.3
> But the code is the same in master branch.
> Reporter: B. van Mensvoort
> Priority: Critical
> Fix For: Master
>
> Attachments: logcat.txt
>
>
> My app uses navigator.camera.getPicture to select files from a library.
> After selecting some files, the app crashes. Some files go well and it
> doesn't seem to happen on all devices.
> The crash happens in the FileHelper.java file and it the exception is:
> {{java.lang.NumberFormatException: For input string:
> "raw:/storage/emulated/0/Download/filename.PDF"}}
> It seems to be caused the way files are saved on the device. The urls of the
> files are different. When resaving the file, the URL can be as expected.
> Expected URL:
> {{content://com.android.providers.downloads.documents/document/1111}}
> Error URL:
> {{content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Ffilename.pdf}}
> The fix is the same as:
> [https://github.com/severianremi/uCrop/commit/9e2bb067631ac3bd3817c0fb55c51db3d61edfe0]
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]