无法从Cloud Storage获取正确的下载URL

时间:2019-09-08 16:29:47

标签: android firebase firebase-storage

我想要一个合适的URL从Cloud Storage下载图像并使用Picasso显示到图像视图,但是我一直在努力获取想要的东西。

我在下面尝试了一下方法,以确认哪种方法是正确的用法。

// storage URL
// gs://fir-image-78ab8.appspot.com/uploads/1567944666079

// download URL(what I want to achieve)
// https://firebasestorage.googleapis.com/v0/b/fir-image-78ab8.appspot.com/o/uploads%2F1567944666079?alt=media&token=35843999-af43-4666-87d2-721833163550


fun getImageFromURL() {

    var test1 = FirebaseStorage.getInstance().getReference()
    var test2 = FirebaseStorage.getInstance().getReference().child("uploads/1567938332065")
    var test3 = FirebaseStorage.getInstance().getReference().child("uploads/1567938332065").downloadUrl
    var test4 = FirebaseStorage.getInstance().getReference("uploads/1567938332065")
    var test5 = FirebaseStorage.getInstance().getReferenceFromUrl("https://firebasestorage.googleapis.com/v0/b/fir-image-78ab8.appspot.com/o/uplods%1567938332065")



    Log.d("test", "======================")
    Log.d("test", " result1 " + test1.toString())

    Log.d("test", "======================")
    Log.d("test", " result2 " + test2.toString())

    Log.d("test", "======================")
    Log.d("test", " result3 " + test3.toString())

    Log.d("test", "======================")
    Log.d("test", " result4 " + test4.toString())

    Log.d("test", "======================")
    Log.d("test", " result5 " + test5.toString())


    Picasso.get()
        .load("test1")
        .into(imageView)
}

测试结果

====================================
result1 gs://fir-image-78ab8.appspot.com/
====================================
result2 gs://fir-image-78ab8.appspot.com/uploads/1567938332065
====================================
result3 com.google.android.gms.tasks.zzu@c992d1b
====================================
result4 gs://fir-image-78ab8.appspot.com/uploads/1567938332065
====================================
result5 gs://fir-image-78ab8.appspot.com/uplods%1567938332065

我无法获得值https://firebasestorage.googleapis.com/v0/b/fir-image-78ab8.appspot.com/o/uploads%2F1567944666079?alt=media&token=35843999-af43-4666-87d2-721833163550

在这种情况下我该怎么办?

如果我错过了什么。请让我知道。

0 个答案:

没有答案