Nitneuq
Nitneuq

Reputation: 5012

How to upload .flr .mp3 .jpg files from firebase storage with flutter

My app is close to reaching the 150mb limit for the Playstore. I have .jpg .mp3 and .flr files taking up space in the assets folder. I would like to store them on firebase storage to call them when needed. Is it possible ? And how ? Thank you

For exemple I have a file upload on firebase storage with the name : image1.jpg

instead of

new Image.asset(
      "assets/image1.jpg",
      fit: BoxFit.fitWidth,
    ).image,

I search to have something like

 -> download locally "image1.jpg" from firebase storage
 -> display  new Image.asset(
          "path of dowloaded image1.jpg from local folder",
          fit: BoxFit.fitWidth,
        ).image,
 -> remove image1.jpg after close page

Upvotes: 0

Views: 141

Answers (1)

Roopa M
Roopa M

Reputation: 3009

You can get downloadableURL for the image and use it in app just like @Rohit mentioned in the comment.

printUrl() async { 
     StorageReference ref = 
         FirebaseStorage.instance.ref().child("images/sky.jpg"); 
     String url = (await ref.getDownloadURL()).toString(); 
     print(url); 
}

You can go through this documentations for Upload files with Cloud Storage on Flutter https://firebase.google.com/docs/storage/flutter/upload-files

Upvotes: 1

Related Questions