for (UploadTask uploadTask : mStorageRef.getActiveUploadTasks()) {
if (!uploadTask.isCanceled()) {
Log.d(TAG, "Canceling task");
uploadTask.cancel();
}
}
--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/7zFyDrKdxD8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e9009c73-de9a-40cf-8dd0-6c7dc8464fd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
StorageTask<UploadTask.TaskSnapshot> myTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.runOnUiThread(new Runnable() {
@Override
public void run() {
FirebaseStorage.getInstance().setMaxUploadRetryTimeMillis(15000); //<== turn off your data connection to see the retry error after 15 seconds
StorageReference ref = FirebaseStorage.getInstance().getReference("bigFile.txt");
StringBuilder builder = new StringBuilder();
for(int i=0; i<50;i++) { //50 MB should be enough to cancel while in flight.
for(int j=0;j<1024;j++) {
for (int k = 1; k<1024;k++) {
builder.append('3');
}
}
}
myTask = ref.putBytes(builder.toString().getBytes()).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Log.w("TAG","success!");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("TAG", e.toString());
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
Log.d("TAG", "progress.");
}
});
}
});
}
public void onCancelClick(View v) {
myTask.cancel();
}
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/25870542-cbbc-4efb-8260-0d1192ba2c9d%40googlegroups.com.