-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Add monitoring and management to uploads #531
Add monitoring and management to uploads #531
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
41ea484
to
c151dd5
Compare
Thank you very much for your contribution. It is great with the file split of |
I'll get on that real soon, thanks @szakarias!
…On Mon, May 7, 2018, 8:31 AM Sarah Zakarias ***@***.***> wrote:
Thank you very much for your contribution.
It is great with the file split of firebase_storage.dart. For review
purposes, please do it separately in its own PR either before or after the
change. Also please make sure all the tests, format, analyze etc. pass.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#531 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AP829ncbtBJHbX81AmdEgR6HXFXzgglTks5twD6bgaJpZM4Tyac6>
.
|
In order to do the review, please rebase and fix the conflicts and failing tests. |
b7d8155
to
a808b4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the first batch of comments.
In addition, please focus this PR on the relevant change. That is, remove all the unnecessary style and format changes such as renaming, reordering, etc.
@required StorageReference reference, | ||
StorageMetadata metadata, | ||
}) : _storage = storage, | ||
_reference = reference, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for changing the argument from path to a storageReference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code similarity with repo.
final FirebaseStorage _firebaseStorage; | ||
final String _path; | ||
StorageUploadTask({ | ||
@required FirebaseStorage storage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change to named parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code similarity with repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style changes should be done separately.
abstract class StorageUploadTask { | ||
final FirebaseStorage _firebaseStorage; | ||
final String _path; | ||
StorageUploadTask({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor should remain private.
|
||
/// Returns a StorageTaskSnapshot on complete, or throws error | ||
Future<StorageTaskSnapshot> _start() async { | ||
_handle = await _platformMethod().then<int>((dynamic result) => result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just _handle = await _platformMethod();
/// Returns a StorageTaskSnapshot on complete, or throws error | ||
Future<StorageTaskSnapshot> _start() async { | ||
_handle = await _platformMethod().then<int>((dynamic result) => result); | ||
return await _storage._methodStream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for await
since you are returning a Future.
The multiple stream transformations makes the code hard to read. Let's try with a single where
and a single map
like this
final StorageTaskEvent event = await _storage._methodStream
.where(...)
.map((MethodCall call) {...})
.firstWhere(...);
return event.snapshot;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather prefer the multiple .where
and .map
to break out the transformation steps whilst using the fat arrow notation. Is there a performance benefit to combining into code blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is definitely a performance overhead in having several transformation, but the main issue here is readability. You could also try with some helper functions that encapsulate the logic you want to express.
String path, StorageMetadata metadata) | ||
: super._(firebaseStorage, path, metadata); | ||
class _StorageFileUploadTask extends StorageUploadTask { | ||
_StorageFileUploadTask({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change the constructor signature unless it is functionally needed.
String path, StorageMetadata metadata) | ||
: super._(firebaseStorage, path, metadata); | ||
class _StorageDataUploadTask extends StorageUploadTask { | ||
_StorageDataUploadTask({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above regarding constructor signature change.
StorageFileUploadTask._(this._file, FirebaseStorage firebaseStorage, | ||
String path, StorageMetadata metadata) | ||
: super._(firebaseStorage, path, metadata); | ||
class _StorageFileUploadTask extends StorageUploadTask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this class private is a breaking change. Let's leave it public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want to do this? This will introduce some ambiguity for the end user. Why expose StorageFileUploadTask
and StorageDataUploadTask
when the only functionality that would be needed is found in the base class, StorageUploadTask
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide on this, it should be done in a separate PR.
StorageDataUploadTask._(this._bytes, FirebaseStorage firebaseStorage, | ||
String path, StorageMetadata metadata) | ||
: super._(firebaseStorage, path, metadata); | ||
class _StorageDataUploadTask extends StorageUploadTask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this public too.
@@ -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 <[email protected]> | |||
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_storage | |||
version: 0.3.4 | |||
version: 0.3.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it ends up being a breaking change, increment the minor version instead.
@pauldemarco Will you be able to continue working on this? It's totally fine if not; we can take it over (though it might take longer). I'm just asking because I'm trying to clean out our review queue. |
Hi @Hixie, yep i've got some time carved out later this week for this. |
@szakarias Many of those formatting and internal changes were to increase code similarity between other plugins in this repo, like FirebaseDatabase and CloudFirestore. I'll take a look at what might be unnecessary and revert, as well as apply those other requests later this week. Thanks! |
StorageFileUploadTask._(this._file, FirebaseStorage firebaseStorage, | ||
String path, StorageMetadata metadata) | ||
: super._(firebaseStorage, path, metadata); | ||
class _StorageFileUploadTask extends StorageUploadTask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide on this, it should be done in a separate PR.
/// Returns a StorageTaskSnapshot on complete, or throws error | ||
Future<StorageTaskSnapshot> _start() async { | ||
_handle = await _platformMethod().then<int>((dynamic result) => result); | ||
return await _storage._methodStream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is definitely a performance overhead in having several transformation, but the main issue here is readability. You could also try with some helper functions that encapsulate the logic you want to express.
final FirebaseStorage _firebaseStorage; | ||
final String _path; | ||
StorageUploadTask({ | ||
@required FirebaseStorage storage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style changes should be done separately.
// found in the LICENSE file. | ||
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our license header should say Chromium Authors
674dc7a
to
c0d4317
Compare
@szakarias I reverted a bunch of styling changes, and applied the changes for _setState. It's unclear whether it's the PR author's responsibility to update the CHANGELOG and pubspec version, so I left it alone for now. Let me know of anything else. Thanks! |
Thanks for your update. I can see you removed the example code. Could you update the example again to exercise some of the new features? Also going forward, please don't squash commits as this makes reviewing harder. |
@pauldemarco Please let us know if you be able to continue working on this. If you don't have an opportunity to do so that's totally fine, we will in due course fix the remaining issues and land the patch. Thanks for your contributions so far! |
@Hixie @szakarias I'll be able to include a cleaned up example this week, thanks for your patience. |
a6da37d
to
dd52c7a
Compare
This reverts commit 1a9d099
ec250fe
to
22df07d
Compare
CLAs look good, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pauldemarco Once you remove the unnecessary 'CANCELLED' print, I think this is good to merge.
break; | ||
case StorageTaskEventType.failure: | ||
isComplete = true; | ||
print('CANCELLED'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this print statement.
* Upload monitoring and management added for Android and iOS.
* Upload monitoring and management added for Android and iOS.
This reverts commit 995967c.
* Upload monitoring and management added for Android and iOS.
This PR uses similar techniques found in other firebase plugins to add management and monitoring of uploads (StorageUploadTask) to Firebase Storage.