【问题标题】:broken image displaying when using Firebase photoURL使用 Firebase photoURL 时显示的图像损坏
【发布时间】:2022-07-13 03:29:04
【问题描述】:

我已使用 firebase 电子邮件和密码身份验证来注册用户,并将用户的 photoURL 设置为用户上传的图像。当我将图像的 src 设置为 user.photoURL 时,图像不会显示 - 但是当我检查代码时,我可以看到 src photoURL 是正确的。有谁知道为什么不显示?

这是图片的代码

<img className="profile-div__img" src={user.photoURL} alt="Profile picture"/>

这是我检查代码时显示的内容(但显示损坏的 img)

<img class="profile-div__img" src="https://firebasestorage.googleapis.com/v0/b/hobbi-react-app.appspot.com/o/thumbnails%2FKArVySiyqUfdp9YEfSpecVAnwHz2%2FIMG_3DB77D57E811-1.jpeg?alt=media&amp;token=10948c92-b051-4e32-b852-a413c917a61c" alt="Profile picture">

这就是我设置 photoURL 的方式

// updateProfile(res.user, {displayName});
const uploadPath = `thumbnails/${res.user.uid}/${thumbnail.name}`;
const img = await uploadBytes(ref(storage, uploadPath, thumbnail));
const imgUrl = await getDownloadURL(img.ref);

// add display AND PHOTO_URL name to user
await updateProfile(res.user, { displayName, photoURL: imgUrl });

【问题讨论】:

    标签: javascript firebase-authentication firebase-storage


    【解决方案1】:

    我目前遇到了这个问题。你有办法解决吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-14
      • 2013-09-13
      • 1970-01-01
      • 2017-12-07
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      • 2018-05-05
      相关资源
      最近更新 更多