4

There are many examples of uploading a file to firebase and getting a downloadUrl but there's no example that I found to get the DownloadURL for an image and using it in a Flutter widget.

This is the one which is related to uploading a file

final StorageReference ref =
    FirebaseStorage.instance.ref().child("foo$rand.txt");
final StorageUploadTask uploadTask = ref.put(file);
final Uri downloadUrl = (await uploadTask.future).downloadUrl;
final http.Response downloadData = await http.get(downloadUrl);

Can anyone give an example of one where the file already exists in firebase and how to get a download link?

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
user3217522
  • 5,786
  • 7
  • 26
  • 34

1 Answers1

3

You can just use the Storage API to download, like with upload

someMethod() async {
  var data = await FirebaseStorage.instance.ref().child("foo$rand.txt").getData();
  var text = new String.fromCharCodes(data);
  print(data);
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567