如何使Firebase存储的图像加载速度更快? [英] How can I make image load faster from firebase storage?

查看:102
本文介绍了如何使Firebase存储的图像加载速度更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从firebase存储中加载图片的速度非常缓慢,在我的网页上显示图片的时间超过了 2秒。有没有什么办法来加载图像加载?当给世界读取访问权限时它会播种吗?像:允许读:如果是true

请指导我,从firebase存储上传和下载图像的最佳方式是什么?
$ b 以下是我的存储规则:

  service firebase。存储{
match /b/test-project-faac7.appspot.com/o {
match / {allPaths = **} {
allow read:if request.auth!= null;
允许写入:if request.auth!= null;





代码获得下载地址:

  this.storage.ref(item.imgQuestion).getDownloadURL()。then(url => {
item.imgQuestionUrl = url;
})


解决方案

你可以在 upload 之后创建一个 cloud-function 来替换原始图像。你可以按照这个示例来得到一些想法。您需要注意存储上传以触发您的功能。


Loading images from firebase storage is very slow, it was taking more than 2sec to show image in my web page. Is there any way to seed up image loading? Will it seed up when give read access to world Like: allow read: if true?

Please guide me, what is the best way to upload and download images from firebase storage? Thanks.

Following is my Storage Rule:

service firebase.storage {
  match /b/test-project-faac7.appspot.com/o {
    match /{allPaths=**} {
      allow read: if request.auth != null;
      allow write: if request.auth != null;
    }
  }
}

Code to get Download Url :

 this.storage.ref(item.imgQuestion).getDownloadURL().then(url => {
    item.imgQuestionUrl = url;
 })

解决方案

You could create a cloud-function where the image can be compressed after upload and replace the original image. You can follow this sample to get some idea. You will need to watch for storage upload to trigger your functions.

这篇关于如何使Firebase存储的图像加载速度更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆