From 0c988413de6353275648fa84df9be9d8fd4fb365 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 7 Feb 2024 14:40:57 +0100 Subject: [PATCH] Add uri as fallback --- .../wordpress/android/ui/ShareIntentReceiverActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java index faafa640d716..6d100f6d2c07 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java @@ -4,6 +4,7 @@ import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -116,7 +117,11 @@ private void downloadExternalMedia() { } private boolean isAllowedMediaType(@NonNull Uri uri) { - String filePath = uri.getPath(); + String filePath = MediaUtils.getRealPathFromURI(this, uri); + // For cases when getRealPathFromURI returns an empty string + if (TextUtils.isEmpty(filePath)) { + filePath = String.valueOf(uri); + } return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath); }