Firebase如何从firebase存储中获取Image Url? [英] Firebase how to get Image Url from firebase storage?

查看:178
本文介绍了Firebase如何从firebase存储中获取Image Url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我使用以下代码从Storage of Firebase获取图片:

Right now i am fetching image from Storage of Firebase by using below code :

mStoreRef.child("photos/" + model.getBase64Image())
          .getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                        @Override
                        public void onSuccess(Uri uri) {
                            // Got the download URL for 'photos/profile.png'

                        }
                    }).addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            // Handle any errors
                            Toast.makeTextthis, "image not dowloaded", Toast.LENGTH_SHORT).show();
                        }
                    });

可以获得此图片中显示的URL .. ???

推荐答案

请点击此链接 - https://firebase.google .com / docs / storage / android / download-files #download_data_via_url

Follow this link -https://firebase.google.com/docs/storage/android/download-files#download_data_via_url

    storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
        @Override
        public void onSuccess(Uri uri) {
            // Got the download URL for 'users/me/profile.png'
            Uri downloadUri = taskSnapshot.getMetadata().getDownloadUrl();
            generatedFilePath = downloadUri.toString(); /// The string(file link) that you need
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // Handle any errors
        }
    });

这篇关于Firebase如何从firebase存储中获取Image Url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆