Android 将文件上载到firebase存储的代码中有哪两项任务?

Android 将文件上载到firebase存储的代码中有哪两项任务?,android,uri,firebase-storage,Android,Uri,Firebase Storage,根据文档,这是将文件上载到Firebase存储并检索下载uri的代码: Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() { @Override public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot&

根据文档,这是将文件上载到Firebase存储并检索下载uri的代码:

    Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
    @Override
    public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
        if (!task.isSuccessful()) {
            throw task.getException();
        }

        // Continue with the task to get the download URL
        return ref.getDownloadUrl();
    }
    }).addOnCompleteListener(new OnCompleteListener<Uri>() {
        @Override
        public void onComplete(@NonNull Task<Uri> task) {
            if (task.isSuccessful()) {
                Uri downloadUri = task.getResult();
            } else {
                 // Handle failures
                 // ...
            }
        }
    });

从代码中可以看到,代码中有两个任务,continueWithTask方法上的任务和addOnCompleteListener方法上的任务。我想知道我必须检查哪个任务是否成功,以确保文件上载成功

谢谢你的回答。那么,任务任务的成功代表什么呢?它只代表成功上传的文件。为了获得其url以再次下载,第二个任务任务必须完成。如果您只需要上传文件,而不关心其下载链接,则无需执行第二个任务
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
    @Override
    public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
        if (!task.isSuccessful()) {
            throw task.getException();
        }

        // Continue with the task to get the download URL
        return ref.getDownloadUrl();
    }
    }).addOnCompleteListener(new OnCompleteListener<Uri>() {
        @Override
        public void onComplete(@NonNull Task<Uri> task) {
            if (task.isSuccessful()) {
                -> **This is the Success Case for you**
                Uri downloadUri = task.getResult();
            } else {
                 -> **In this case File Uploaded Successfully But You failed to get its URL,
                   Again send this call again with storage reference. No need to send other 
                   call to upload the file again because its uploaded already on FireStore.**
                }
            }
        });