How to get URL from Firebase Storage getDownloadURL

后端 未结 10 2374
小蘑菇
小蘑菇 2020-11-21 04:54

I\'m trying to get the \"long term persistent download link\" to files in our Firebase storage bucket. I\'ve changed the permissions of this to

service fireb         


        
10条回答
  •  佛祖请我去吃肉
    2020-11-21 05:52

    You can Upload images to firestore and get it's download URL as below function:

      Future uploadPic(File _image) async {
    
        String fileName = basename(_image.path);
        StorageReference firebaseStorageRef = FirebaseStorage.instance.ref().child(fileName);
        StorageUploadTask uploadTask = firebaseStorageRef.putFile(_image);
        var downloadURL = await(await uploadTask.onComplete).ref.getDownloadURL();
        var url =downloadURL.toString();
    
       return url;
    
      }
    

提交回复
热议问题