为用户图像另存为 gs:// 或 https://。哪种方式值得推荐?
Saving as gs:// or https:// for user's image. which way is recommendable?
我正在为我的 Android 应用程序使用 Firebase。
每个用户都有自己的个人资料图片。
但目前,我正在将他们的图像保存到 Firebase 存储和 Firebase 存储中。
Firebase 存储
/avatar1.png
/avatar2.png
/avatar3.png
Firebase Firestore
/user/AAA/profile_uri -> "gs://.../avatar1.png"
val gsReference = storage.getReferenceFromUrl(document.data["profile_url"] as String)
gsReference.downloadUrl.addOnSuccessListener {
val imageURL = it.toString()
context?.let { it1 -> Glide.with(it1).load(imageURL).into(binding.imgProfileMypicture)
}}
但我认为在每次用户调用时从 gs 协议中检索 url 是一个很大的冗余。
所以我想将原始 https url 保存到 Firestore,但它在 url 的尾部有一个标记,如下所示:https://firebasestorage.googleapis.com/v0/b/project-pow-265e1.appspot.com/o/profile%2Favatar2.png?alt=media&token={token}
我的问题是...
- 我不知道在 Firestore 上保存原始 url 是否值得推荐。
- 如果是这样,如何在不从存储 API.
调用 downloadUrl 的情况下获取 https url
到目前为止我提到的内容:https://firebase.google.com/docs/storage/web/download-files
使用 Firebase 存储时,最常用和最推荐的方法是将文件的 public Url 保存在 Cloud Firestore 中。这是有主要原因的。
当使用 gs://
协议时,应用程序的性能会降低,因为每次调用文件时,您都必须 resolve promise 以获得 public link。
所以对于你的问题,
- 建议在 Firestore 上保存原始 url,这是一种常用的技术。
- 除使用
getDownloadURL()
方法外,没有任何其他方法可以检索文件的 public Url。
我正在为我的 Android 应用程序使用 Firebase。
每个用户都有自己的个人资料图片。
但目前,我正在将他们的图像保存到 Firebase 存储和 Firebase 存储中。
Firebase 存储
/avatar1.png
/avatar2.png
/avatar3.png
Firebase Firestore
/user/AAA/profile_uri -> "gs://.../avatar1.png"
val gsReference = storage.getReferenceFromUrl(document.data["profile_url"] as String)
gsReference.downloadUrl.addOnSuccessListener {
val imageURL = it.toString()
context?.let { it1 -> Glide.with(it1).load(imageURL).into(binding.imgProfileMypicture)
}}
但我认为在每次用户调用时从 gs 协议中检索 url 是一个很大的冗余。
所以我想将原始 https url 保存到 Firestore,但它在 url 的尾部有一个标记,如下所示:https://firebasestorage.googleapis.com/v0/b/project-pow-265e1.appspot.com/o/profile%2Favatar2.png?alt=media&token={token}
我的问题是...
- 我不知道在 Firestore 上保存原始 url 是否值得推荐。
- 如果是这样,如何在不从存储 API.
调用 downloadUrl 的情况下获取 https url 到目前为止我提到的内容:https://firebase.google.com/docs/storage/web/download-files
使用 Firebase 存储时,最常用和最推荐的方法是将文件的 public Url 保存在 Cloud Firestore 中。这是有主要原因的。
当使用 gs://
协议时,应用程序的性能会降低,因为每次调用文件时,您都必须 resolve promise 以获得 public link。
所以对于你的问题,
- 建议在 Firestore 上保存原始 url,这是一种常用的技术。
- 除使用
getDownloadURL()
方法外,没有任何其他方法可以检索文件的 public Url。