parent
0dc87e95d3
commit
9f0a811028
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,3 +1,13 @@
|
|||
## 3.0.3
|
||||
|
||||
#### Web
|
||||
- Removes analysis_options.yaml from the plugin and fixes the _Don't import implementation files from another package_ warning (#746).
|
||||
#### Android
|
||||
- Addresses an issue where bytes might be missing after first picking when `withData` is set to `true`. ([#616](https://github.com/miguelpruivo/flutter_file_picker/issues/616)).
|
||||
|
||||
#### Desktop (GO)
|
||||
- Patches README import path. (Thank you @voynichteru)
|
||||
|
||||
## 3.0.2+2
|
||||
- Fixes [#725](https://github.com/miguelpruivo/flutter_file_picker/issues/725).
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ rootProject.allprojects {
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 30
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
|
|
|
@ -99,17 +99,8 @@ public class FileUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static FileInfo openFileStream(final Context context, final Uri uri, boolean withData) {
|
||||
|
||||
Log.i(TAG, "Caching from URI: " + uri.toString());
|
||||
FileOutputStream fos = null;
|
||||
final FileInfo.Builder fileInfo = new FileInfo.Builder();
|
||||
final String fileName = FileUtils.getFileName(uri, context);
|
||||
final String path = context.getCacheDir().getAbsolutePath() + "/file_picker/" + (fileName != null ? fileName : new Random().nextInt(100000));
|
||||
|
||||
final File file = new File(path);
|
||||
|
||||
if(file.exists() && withData) {
|
||||
public static void loadData(final File file, FileInfo.Builder fileInfo) {
|
||||
try {
|
||||
int size = (int) file.length();
|
||||
byte[] bytes = new byte[size];
|
||||
|
||||
|
@ -123,8 +114,23 @@ public class FileUtils {
|
|||
Log.e(TAG, "Failed to close file streams: " + e.getMessage(), null);
|
||||
}
|
||||
fileInfo.withData(bytes);
|
||||
} else {
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load bytes into memory with error " + e.toString() + ". Probably the file is too big to fit device memory. Bytes won't be added to the file this time.");
|
||||
}
|
||||
}
|
||||
|
||||
public static FileInfo openFileStream(final Context context, final Uri uri, boolean withData) {
|
||||
|
||||
Log.i(TAG, "Caching from URI: " + uri.toString());
|
||||
FileOutputStream fos = null;
|
||||
final FileInfo.Builder fileInfo = new FileInfo.Builder();
|
||||
final String fileName = FileUtils.getFileName(uri, context);
|
||||
final String path = context.getCacheDir().getAbsolutePath() + "/file_picker/" + (fileName != null ? fileName : new Random().nextInt(100000));
|
||||
|
||||
final File file = new File(path);
|
||||
|
||||
if(!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
fos = new FileOutputStream(path);
|
||||
|
@ -139,19 +145,6 @@ public class FileUtils {
|
|||
out.write(buffer, 0, len);
|
||||
}
|
||||
|
||||
if(withData) {
|
||||
try {
|
||||
FileInputStream fis = null;
|
||||
byte[] bytes = new byte[(int) file.length()];
|
||||
fis = new FileInputStream(file);
|
||||
fis.read(bytes);
|
||||
fis.close();
|
||||
fileInfo.withData(bytes);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load bytes into memory with error " + e.toString() + ". Probably the file is too big to fit device memory. Bytes won't be added to the file this time.");
|
||||
}
|
||||
}
|
||||
|
||||
out.flush();
|
||||
} finally {
|
||||
fos.getFD().sync();
|
||||
|
@ -170,6 +163,10 @@ public class FileUtils {
|
|||
|
||||
Log.d(TAG, "File loaded and cached at:" + path);
|
||||
|
||||
if(withData) {
|
||||
loadData(file, fileInfo);
|
||||
}
|
||||
|
||||
fileInfo
|
||||
.withPath(path)
|
||||
.withName(fileName)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:file_picker/src/file_picker_web.dart';
|
||||
import 'package:file_picker/_internal/file_picker_web.dart';
|
||||
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import 'dart:typed_data';
|
|||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
import 'file_picker_result.dart';
|
||||
import 'platform_file.dart';
|
||||
import '../src/file_picker_result.dart';
|
||||
import '../src/platform_file.dart';
|
||||
|
||||
class FilePickerWeb extends FilePicker {
|
||||
late Element _target;
|
|
@ -1,7 +1,7 @@
|
|||
name: file_picker
|
||||
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
|
||||
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
||||
version: 3.0.2+2
|
||||
version: 3.0.3
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
@ -26,4 +26,4 @@ flutter:
|
|||
pluginClass: FilePickerPlugin
|
||||
web:
|
||||
pluginClass: FilePickerWeb
|
||||
fileName: src/file_picker_web.dart
|
||||
fileName: _internal/file_picker_web.dart
|
||||
|
|
Loading…
Reference in New Issue