From 0117f578960662129a975dba215df75ca0f715a1 Mon Sep 17 00:00:00 2001
From: xuty <xty50337@hotmail.com>
Date: Wed, 5 Jan 2022 00:03:28 +0800
Subject: [PATCH] Stable release

---
 CHANGELOG.md         |  4 ++++
 README.md            | 20 ++++++++++++++++++++
 lib/src/utils.dart   |  4 +---
 pubspec.yaml         |  2 +-
 test/minio_test.dart | 16 ++++++++++++++++
 5 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6a5452..8968530 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 3.3.3
+- Fix empty upload error
+- Update README.md
+
 # 3.3.3-pre
 - Update stream file upload
 
diff --git a/README.md b/README.md
index ecfa3ea..b2bb908 100644
--- a/README.md
+++ b/README.md
@@ -76,6 +76,26 @@ For complete example, see: [example]
 
 > To use `fPutObject()` and `fGetObject`, you have to `import 'package:minio/io.dart';`
 
+**File upload with progress**
+```dart
+import 'package:minio/minio.dart';
+
+void main() async {
+  final minio = Minio(
+    endPoint: 'play.min.io',
+    accessKey: 'Q3AM3UQ867SPQQA43P2F',
+    secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
+  );
+
+  await minio.putObject(
+    'mybucket', 
+    'myobject', 
+    Stream<Uint8List>.value(Uint8List(1024)),
+    onProgress: (bytes) => print('$bytes uploaded'),
+  );
+}
+```
+
 **Get object**
 
 ```dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 307cf27..0d43fe4 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -108,9 +108,7 @@ class MinChunkSize extends StreamTransformerBase<Uint8List, Uint8List> {
       yield buffer.takeBytes();
     }
 
-    if (buffer.isNotEmpty) {
-      yield buffer.takeBytes();
-    }
+    yield buffer.takeBytes();
   }
 }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 3f2abbf..f4c483e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: minio
 description: Unofficial MinIO Dart Client SDK that provides simple APIs to access any Amazon S3 compatible object storage server.
-version: 3.3.3-pre
+version: 3.3.3
 homepage: https://github.com/xtyxtyx/minio-dart
 issue_tracker: https://github.com/xtyxtyx/minio-dart/issues
 
diff --git a/test/minio_test.dart b/test/minio_test.dart
index 9a1df13..7b970c2 100644
--- a/test/minio_test.dart
+++ b/test/minio_test.dart
@@ -427,6 +427,22 @@ void testPutObject() {
       expect(stat.size, equals(dataLength));
     });
 
+    test('empty stream upload works', () async {
+      final objectName = uniqueName();
+      await minio.putObject(bucketName, objectName, Stream.empty());
+      final stat = await minio.statObject(bucketName, objectName);
+      await minio.removeObject(bucketName, objectName);
+      expect(stat.size, equals(0));
+    });
+
+    test('zero byte stream upload works', () async {
+      final objectName = uniqueName();
+      await minio.putObject(bucketName, objectName, Stream.value(Uint8List(0)));
+      final stat = await minio.statObject(bucketName, objectName);
+      await minio.removeObject(bucketName, objectName);
+      expect(stat.size, equals(0));
+    });
+
     test('multipart file upload works', () async {
       final objectName = uniqueName();
       final dataLength = 12 * 1024 * 1024;
-- 
GitLab