From 6882ed17779ad28037d5e95fbb738f97884cb0a2 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com> Date: Sun, 4 Aug 2019 11:39:12 +0000 Subject: [PATCH 1/3] initial --- packages/firebase_storage/CHANGELOG.md | 6 ++++++ packages/firebase_storage/README.md | 20 +++++++++++++++++++ .../firebase_storage/lib/src/upload_task.dart | 1 - packages/firebase_storage/pubspec.yaml | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/firebase_storage/CHANGELOG.md b/packages/firebase_storage/CHANGELOG.md index d9fbd1d1fe6c..86b8003b2fea 100644 --- a/packages/firebase_storage/CHANGELOG.md +++ b/packages/firebase_storage/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.0.5 +* Removed automatic print statements for `StorageTaskEvent`'s. + If you want to see the event status in your logs now, you will have to use the following: + `storageReference.put{File/Data}(..).events.listen((event) => print('EVENT ${event.type}'));` +* Updated `README.md` to explain the above. + ## 3.0.4 * Update google-services Android gradle plugin to 4.3.0 in documentation and examples. diff --git a/packages/firebase_storage/README.md b/packages/firebase_storage/README.md index 370f50abda11..6b73a4c4fe1e 100755 --- a/packages/firebase_storage/README.md +++ b/packages/firebase_storage/README.md @@ -9,8 +9,28 @@ For Flutter plugins for other Firebase products, see [FlutterFire.md](https://gi *Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! ## Usage + To use this plugin, add `firebase_storage` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). +### Logging + +If you wish to see status events for your upload tasks in your logs, you should listen to the `StorageUploadTask.events` stream. +This could look like the following if you are using `StorageReference.putData`: + +```dart +final StorageReference storageReference = FirebaseStorage().ref().child(path); + +final StorageUploadTask uploadTask = storageReference.putData(data); + +final StreamSubscription streamSubscription = uploadTask.events.listen((event) { + print('EVENT ${event.type}'); +}); + +// Cancel your subscription when done. +await uploadTask.onComplete; +streamSubscription.cancel(); +``` + ## Getting Started See the `example` directory for a complete sample app using Firebase Cloud Storage. diff --git a/packages/firebase_storage/lib/src/upload_task.dart b/packages/firebase_storage/lib/src/upload_task.dart index 9c263779e7e1..70d4f9ebcc61 100644 --- a/packages/firebase_storage/lib/src/upload_task.dart +++ b/packages/firebase_storage/lib/src/upload_task.dart @@ -56,7 +56,6 @@ abstract class StorageUploadTask { void _changeState(StorageTaskEvent event) { _resetState(); - print('EVENT ${event.type}'); switch (event.type) { case StorageTaskEventType.progress: isInProgress = true; diff --git a/packages/firebase_storage/pubspec.yaml b/packages/firebase_storage/pubspec.yaml index c479081607f1..cffac66c8a1b 100755 --- a/packages/firebase_storage/pubspec.yaml +++ b/packages/firebase_storage/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Cloud Storage, a powerful, simple, and cost-effective object storage service for Android and iOS. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_storage -version: 3.0.4 +version: 3.0.5 flutter: plugin: From e4472e485fe30c066babd6916ff48955e98ad919 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com> Date: Sun, 4 Aug 2019 11:44:12 +0000 Subject: [PATCH 2/3] Further explanation --- packages/firebase_storage/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/firebase_storage/README.md b/packages/firebase_storage/README.md index 6b73a4c4fe1e..96d7a1ceb9cf 100755 --- a/packages/firebase_storage/README.md +++ b/packages/firebase_storage/README.md @@ -23,6 +23,11 @@ final StorageReference storageReference = FirebaseStorage().ref().child(path); final StorageUploadTask uploadTask = storageReference.putData(data); final StreamSubscription streamSubscription = uploadTask.events.listen((event) { + // You can use this to notify yourself or your user in any kind of way. + // For example: you could use the uploadTask.events stream in a StreamBuilder instead + // to show your user what the current status is. In that case, you would not need to cancel any + // subscription as StreamBuilder handles this automatically. + // In this case, every StorageTaskEvent concerning the upload is printed to the logs. print('EVENT ${event.type}'); }); From ed6838ee1e6965fbaeb2b4b88f131b26f59d07b2 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com> Date: Sun, 4 Aug 2019 11:58:29 +0000 Subject: [PATCH 3/3] wording --- packages/firebase_storage/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/firebase_storage/README.md b/packages/firebase_storage/README.md index 96d7a1ceb9cf..70aea955cd52 100755 --- a/packages/firebase_storage/README.md +++ b/packages/firebase_storage/README.md @@ -27,7 +27,8 @@ final StreamSubscription streamSubscription = uploadTask.event // For example: you could use the uploadTask.events stream in a StreamBuilder instead // to show your user what the current status is. In that case, you would not need to cancel any // subscription as StreamBuilder handles this automatically. - // In this case, every StorageTaskEvent concerning the upload is printed to the logs. + + // Here, every StorageTaskEvent concerning the upload is printed to the logs. print('EVENT ${event.type}'); });