简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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