由于 taskSnapshot.getDownloadUrl() 已失效,所以我按照 firebase 帖子获取 URLfinal StorageReference ref = storageRef.child("images/mountains.jpg");uploadTask = ref.putFile(file); Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {@Overridepublic 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>() {@Overridepublic void onComplete(@NonNull Task<Uri> task) { if (task.isSuccessful()) { Uri downloadUri = task.getResult(); } else { // Handle failures // ... }}});但我想要 String downloadUri = taskSnapshot.getDownloadUrl().toString();代替 Uri downloadUri = task.getResult();我怎么能做到这一点???
添加回答
举报
0/150
提交
取消