From 55127843c9dd5291d8d3b2947d756b8129ee3573 Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Mon, 4 Jan 2021 15:10:27 +0000 Subject: [PATCH] Updates size to be in bytes instead of kb (#573) --- CHANGELOG.md | 3 +++ .../main/java/com/mr/flutter/plugin/filepicker/FileUtils.java | 2 +- ios/Classes/FileUtils.m | 2 +- lib/src/platform_file.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f0355..4a57703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.1.5 +Updates `size` property from `PlatformFile` to be in bytes instead of kb. + ## 2.1.4 iOS: Fixes iOS ViewController which is nil when UIWindow.rootViewController have changed. ([#525](https://github.com/miguelpruivo/flutter_file_picker/issues/525)). Thank you @devcxm. 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 873dbf4..ffd203e 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 @@ -173,7 +173,7 @@ public class FileUtils { fileInfo .withPath(path) .withName(fileName) - .withSize(Integer.parseInt(String.valueOf(file.length()/1024))); + .withSize(Integer.parseInt(String.valueOf(file.length()))); return fileInfo.build(); } diff --git a/ios/Classes/FileUtils.m b/ios/Classes/FileUtils.m index 2451aad..3cd2000 100644 --- a/ios/Classes/FileUtils.m +++ b/ios/Classes/FileUtils.m @@ -90,7 +90,7 @@ [files addObject: [[[FileInfo alloc] initWithPath: path andName: [path lastPathComponent] - andSize: [NSNumber numberWithLongLong: [@(fileAttributes.fileSize) longLongValue] / 1024] + andSize: [NSNumber numberWithLongLong: [@(fileAttributes.fileSize) longLongValue]] andData: loadData ? [NSData dataWithContentsOfFile:path options: 0 error:nil] : nil] toData]]; } diff --git a/lib/src/platform_file.dart b/lib/src/platform_file.dart index 1e8a814..43bd682 100644 --- a/lib/src/platform_file.dart +++ b/lib/src/platform_file.dart @@ -33,7 +33,7 @@ class PlatformFile { /// File content as stream final Stream> readStream; - /// The file size in KB. + /// The file size in bytes. final int size; /// File extension for this file. diff --git a/pubspec.yaml b/pubspec.yaml index 11f2b6f..48b25d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: 2.1.4 +version: 2.1.5 dependencies: flutter: