如何从Firebase存储获取https:// URL

时间:2020-07-06 13:58:23

标签: android firebase firebase-storage

如何获取此链接的网址? enter image description here

1 个答案:

答案 0 :(得分:0)

您所指的就是文件的下载URL。要获取该URL,您需要按照accessing a file through a URL上的说明进行操作:

StorageReference photoRef = storageRef.child("path/to/photo2.jpg");

photoRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
    @Override
    public void onSuccess(Uri uri) {
        System.out.println(uri.toString());
    }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception exception) {
        throw exception
    }
});