【问题标题】:picasso not loading all images from firebase url in android毕加索没有从android中的firebase url加载所有图像
【发布时间】:2020-02-29 12:23:53
【问题描述】:

我正在尝试通过 url 从 firebase 存储加载图像,但所有图像都没有被加载,有些正在加载,有些没有我正在使用下面的代码和 Picasso 库来加载图像

Picasso.get().load(post.getPost_user_profile_pic_url())
                    .resize(200, 200)
                    .centerCrop()
                    .into(postUserImage);

当我尝试如下使用 Glide 库时

Glide.with(itemView.getContext()).load(post.getPost_user_profile_pic_url()).into(postUserImage);

我得到了以下

W

/Glide: 加载失败 https://firebasestorage.googleapis.com/………… 尺寸 [120x120] com.bumptech.glide.load.engine.GlideException 类:加载资源失败 有1个原因: java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/....................) 调用 GlideException#logRootCauses(String) 了解更多细节 原因(1 之 1):com.bumptech.glide.load.engine.GlideException 类:获取数据失败, 类 java.io.InputStream, 远程

我怎样才能纠正这个问题,以确保所有各自的图像都是从 URL 加载的?

【问题讨论】:

  • 你能粘贴你得到的完整错误吗?为了更好的想法
  • 记住 url 应该使用 HTTPs 而不是 HTTP
  • @RanjeetLuhar 我已经用更多细节更新了错误,正如你所说,它是 HTTPS
  • 如您所见,正在发生 FileNotFoundException。因此,请再次检查图像 url,以便每个系统文件不存在。
  • @RanjeetLuhar 我检查了网址,每个网址都有文件

标签: android firebase picasso android-glide


【解决方案1】:

为了让 Glide 从 URL 加载图像数据,该 URL 需要是公开可读的。由于您希望图像数据受到 Firebase 安全规则的保护,因此您使用的 URL 绝对不是公开的。

要将 Firebase 存储与 Glide 集成,您需要将 Firebase 的 API methods to load the data 之一用于流、内存或本地文件。然后你可以从那里将它传递给 Glide。

我强烈建议直接在您的代码中使用FirebaseUI library that integrates with Glide,或者作为如何构建此类集成的示例。有关从 Firebase 加载数据的具体代码,请参阅此method in the code

【讨论】:

    猜你喜欢
    • 2014-09-26
    • 1970-01-01
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多