taskSnapshot.getDownloadUrl() is deprecated

前端 未结 10 1471
时光说笑
时光说笑 2020-11-27 19:39

Until now, the way to get the url from file on Storage in Firebase, I used to do this taskSnapshot.getDownloadUrl, but nowadays is deprecated, which method I

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 20:18

    Use this implementation for your uploadTask and will work. :)

    uploadTask.addOnSuccessListener(new OnSuccessListener() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Task firebaseUri = taskSnapshot.getStorage().getDownloadUrl();
                    firebaseUri.addOnSuccessListener(new OnSuccessListener() {
                        @Override
                        public void onSuccess(Uri uri) {
    
                            String url = uri.toString();
                            Log.e("TAG:", "the url is: " + url);
    
                            String ref = yourStorageReference.getName();
                            Log.e("TAG:", "the ref is: " + ref);
                        }
                    });
                }
            });
    

提交回复
热议问题