Partial file upload Firebase Storage - Flutter

Viewed 91

I am attaching this listener in a flutter app :

currentTask.snapshotEvents.listen((TaskSnapshot snapshot) {
      double progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
      print('Task state for content $contentID - $name : ${snapshot.state}');
      print('Progress: $progress %');
    });

To the current UploadTask object.

Here are my logs when I turn off internet connection in the middle of the upload and put it back :

I/flutter ( 2792): Attaching listener video to 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021
W/NetworkRequest( 2792): No App Check token for request.
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 0.0 %
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 0.0 %
W/NetworkRequest( 2792): No App Check token for request.
D/UploadTask( 2792): Increasing chunk size to 524288
W/NetworkRequest( 2792): No App Check token for request.
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 8.649253603305764 %
W/System  ( 2792): A resource failed to call release. 
D/UploadTask( 2792): Increasing chunk size to 1048576
W/NetworkRequest( 2792): No App Check token for request.
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 25.94776080991729 %
D/UploadTask( 2792): Increasing chunk size to 2097152
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 60.54477522314035 %
W/NetworkRequest( 2792): No App Check token for request.
W/NetworkRequest( 2792): error sending network request POST https://firebasestorage.googleapis.com/v0/b/myproject.appspot.com/o?name=content%2F7ff837f0-3a6e-11ec-9fef-e7f3f8b31021&uploadType=resumable&upload_id=ADPycdumAfPoeYr-BKuU4NwCosNRFK45V4bkawXqDaleDEtnoG2Gqx3BGI8t3GgQ2nFNj2EoHIxB2L7mHumNOBS6iPyN6g&upload_protocol=resumable
D/UploadTask( 2792): Resetting chunk size to 262144
I/Choreographer( 2792): Skipped 4 frames!  The application may be doing too much work on its main thread.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
I/Choreographer( 2792): Skipped 5 frames!  The application may be doing too much work on its main thread.
W/ExponenentialBackoff( 2792): network unavailable, sleeping.
I/DpmTcmClient( 2792): RegisterTcmMonitor from: $Proxy0
W/NetworkRequest( 2792): No App Check token for request.
W/NetworkRequest( 2792): No App Check token for request.
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 60.54477522314035 %
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.running
I/flutter ( 2792): Progress: 69.19402882644611 %
I/flutter ( 2792): Task state for content 7ff837f0-3a6e-11ec-9fef-e7f3f8b31021 - video : TaskState.success
I/flutter ( 2792): Progress: 69.19402882644611 %
I/flutter ( 2792): Video is uploaded.

And the log Video is uploaded is called after the await of this task, similar to .then().

Why is the TaskState.success when Progress is not 100% ?

This result as a partial file in my bucket, and i can't read it in flutter.

Is this a known bug ? How can i prevent this / or at least know that this is a partial file ? (better than keeping in memory the Progress of all task that are not 100%...)

Thanks in advance

0 Answers
Related