From b4524e3ee96a1430caf956563deea8fc32511326 Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Tue, 17 Sep 2019 10:15:05 +0100 Subject: [PATCH] see changelog (v1.4.1) * Better handling on Android of buggy file managers that return no intent when canceling the file selection even though it returns Activity.RESULT_OK (#111) * removes deprecated Android SDK code and fixes an issue that could prevent some downloaded files from being picked * adds getMultiFile and prevents UI blocking when picking large remote files * updates readme file * fixes an issue that could prevent internal storage files from being properly picked * fixes #126 --- CHANGELOG.md | 4 ++++ .../java/com/mr/flutter/plugin/filepicker/FileUtils.java | 8 +++++--- pubspec.yaml | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e16efb5..098cd3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.1 + +**Bug fix:** Fixes an issue that could result in some cached files, picked from Google Photos (remote file), to have the name set as `null`. + ## 1.4.0+1 **Bug fix:** Fixes an issue that could prevent internal storage files from being properly picked. diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java index 86f6856..4daa659 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java @@ -16,6 +16,7 @@ import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Random; import io.flutter.plugin.common.MethodChannel; @@ -108,7 +109,7 @@ public class FileUtils { return getDataColumn(context, contentUri, selection, selectionArgs); } } else if ("content".equalsIgnoreCase(uri.getScheme())) { - Log.e(TAG, "NO DOCUMENT URI - CONTENT"); + Log.e(TAG, "NO DOCUMENT URI - CONTENT: " + uri.getPath()); if (isGooglePhotosUri(uri)) { return uri.getLastPathSegment(); } else if (isDropBoxUri(uri)) { @@ -116,7 +117,7 @@ public class FileUtils { } return getDataColumn(context, uri, null, null); } else if ("file".equalsIgnoreCase(uri.getScheme())) { - Log.e(TAG, "No DOCUMENT URI - FILE"); + Log.e(TAG, "No DOCUMENT URI - FILE: " + uri.getPath()); return uri.getPath(); } return null; @@ -182,7 +183,8 @@ public class FileUtils { Log.i(TAG, "Caching file from remote/external URI"); FileOutputStream fos = null; - String externalFile = context.getCacheDir().getAbsolutePath() + "/" + FileUtils.getFileName(uri, context); + final String fileName = FileUtils.getFileName(uri, context); + String externalFile = context.getCacheDir().getAbsolutePath() + "/" + (fileName != null ? fileName : new Random().nextInt(100000)); try { fos = new FileOutputStream(externalFile); diff --git a/pubspec.yaml b/pubspec.yaml index b7ff908..2c0688b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: file_picker -description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extensions filtering support. +description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support. author: Miguel Ruivo homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker -version: 1.4.0+1 +version: 1.4.1 dependencies: flutter: