简体   繁体   English

如何使Firebase存储中的图像加载速度更快?

[英]How can I make image load faster from firebase storage?

Loading images from firebase storage is very slow, it was taking more than 2sec to show image in my web page. 从Firebase存储加载图像非常慢,在我的网页中显示图像花了2sec多的时间。 Is there any way to seed up image loading? 有什么方法可以增加图像加载速度吗? Will it seed up when give read access to world Like: allow read: if true ? 当授予对世界的读取访问权限时,是否会播出赞: allow read: if true

Please guide me, what is the best way to upload and download images from firebase storage? 请指导我,从Firebase存储上载和下载图像的最佳方法是什么? 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. 您可以创建cloud-function ,在upload图像后可以压缩图像并替换原始图像。 You can follow this sample to get some idea. 您可以按照以下示例获得一些想法。 You will need to watch for storage upload to trigger your functions. 您将需要注意storage上载以触发功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM