Flutter : getDownloadUrl (firebase storage)


killian

I have a problem with my flutter application. I want to upload an image to firebase storage and get the URL but the getDownloadUrl method doesn't work. Here is my code :

import 'package:firebase_storage/firebase_storage.dart' as firebase_storage;

...

Future<String> addImage(File file, firebase_storage.Reference reference) async{
  firebase_storage.UploadTask task = reference.putFile(file);
  firebase_storage.TaskSnapshot snapshot = task.snapshot;
  String urlString = await snapshot.ref.getDownloadURL();
  return urlString;
}

I think it's because of the new version of firebase_storage(5.2.0)

Mayb3Not

You have to wait for the firebase to store the image then only call getUrl by using await. Similarly, check out this link:https://stackoverflow.com/a/52714376/5408464

   Future<String> addImage(File file, firebase_storage.Reference reference) async{
  final task = await reference.putFile(file);
  final urlString = await (await task.onComplete).ref.getDownloadURL().toString();
  return urlString;
}

Related


Flutter : getDownloadUrl (firebase storage)

killian I have a problem with my flutter application. I want to upload an image to firebase storage and get the URL but the getDownloadUrl method doesn't work. Here is my code : import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; ...

Flutter : getDownloadUrl (firebase storage)

killian I have a problem with my flutter application. I want to upload an image to firebase storage and get the URL but the getDownloadUrl method doesn't work. Here is my code : import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; ...

Flutter : getDownloadUrl (firebase storage)

killian I have a problem with my flutter application. I want to upload an image to firebase storage and get the URL but the getDownloadUrl method doesn't work. Here is my code : import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; ...

Token validity for Firebase Storage getDownloadUrl

Bumblebee I have a problem with the "token" in the url(&token=) when using FirebaseStorage's getDownloadUrl. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 It says to return a "long lived" d

Token validity for Firebase Storage getDownloadUrl

Bumblebee I have a problem with the "token" in the url(&token=) when using FirebaseStorage's getDownloadUrl. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 It says to return a "long lived" d

Token validity for Firebase Storage getDownloadUrl

Bumblebee I have a problem with the "token" in the url(&token=) when using FirebaseStorage's getDownloadUrl. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 It says to return a "long lived" d

Firebase Storage "getDownloadURL" returns undefined

Oy3 I am trying to add an image to firebase storage and use the image URL to add data to firestore. The image is uploading to firebase storage, but if I use the getDownloadUrl method, it doesn't return the URL. It returns this error: Uncaught TypeError: Cannot

Token validity for Firebase Storage getDownloadUrl

Bumblebee I have a problem with the "token" in the url(&token=) when using FirebaseStorage's getDownloadUrl. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 It says to return a "long lived" d

Token validity for Firebase Storage getDownloadUrl

Bumblebee I have a problem with the "token" in the url(&token=) when using FirebaseStorage's getDownloadUrl. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 It says to return a "long lived" d

How to get URL getDownloadURL from Firebase Storage

Jonathan Fager: I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; }

Firebase Storage's getDownloadUrl() method cannot be resolved

Neeraj Sewani To upload images to Firebase Storage, attach to a StorageReference instance . When I override the method, the instance I am calling , but it gives me an erroraddOnSuccessListeneronSuccessgetDownloadUrl()taskSnapshot Cannot resolve method getDownl

getDownloadUrl Firebase Storage returns Null (Android)

Franklin David Macias Avilan I'm working on a small project and I have some questions about firebase Storage and getDownloadUrl. I have uploaded some images on FirebaseStorage but when I try to get the download Url it returns null. Here is the code: Import: im

How to get URL getDownloadURL from Firebase Storage

Jonathan Fager I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; } }

Firebase Storage's getDownloadUrl() method cannot be resolved

Neeraj Sewani To upload images to Firebase Storage, attach to a StorageReference instance . When I override the method, the instance I am calling , but it gives me an erroraddOnSuccessListeneronSuccessgetDownloadUrl()taskSnapshot Cannot resolve method getDownl

How to get URL getDownloadURL from Firebase Storage

Jonathan Fager: I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; }

Firebase Storage's getDownloadUrl() method cannot be resolved

Neeraj Sewani To upload images to Firebase Storage, attach to a StorageReference instance . When I override the method, the instance I am calling , but it gives me an erroraddOnSuccessListeneronSuccessgetDownloadUrl()taskSnapshot Cannot resolve method getDownl

Firebase getDownloadURL cannot set Img Src from storage

Ethan I am trying to replicate the results of this question here . I can call a getDownloadURL()valid database child, but the result it returns can't seem to be set to IMG's src. This is the code I'm currently using to try and get the download URL: var storage

Access Firebase Storage in Flutter

people call all the good names I'm fairly new to Flutter and have never used Firebase before, so my apologies if there is an obvious solution to this. I'm developing a Flutter app that involves logging form submissions and submitting them to a central location

Access Firebase Storage in Flutter

people call all the good names I'm fairly new to Flutter and have never used Firebase before, so my apologies if there is an obvious solution to this. I'm developing a Flutter app that involves logging form submissions and submitting them to a central location

Access Firebase Storage in Flutter

people call all the good names I'm fairly new to Flutter and have never used Firebase before, so my apologies if there is an obvious solution to this. I'm developing a Flutter app that involves logging form submissions and submitting them to a central location

Access Firebase Storage in Flutter

people call all the good names I'm fairly new to Flutter and have never used Firebase before, so my apologies if there is an obvious solution to this. I'm developing a Flutter app that involves logging form submissions and submitting them to a central location