Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full downloadUrl from UploadTaskSnapshot in Flutter?

I correctly receive UploadTaskSnapshot, and the field downloadUrl contains an instance of Uri that parses download link of uploaded file.

How to get storage and downloadUrl as strings?

like image 205
Tree Avatar asked May 18 '18 05:05

Tree


1 Answers

old

final uploadTask = imageStore.putFile(imageFile);
final url = (await uploadTask.future).downloadUrl;

update

This answer https://stackoverflow.com/a/52690889/217408 is now the accurate one.

final ref = FirebaseStorage.instance
    .ref()
    .child('path')
    .child('to')
    .child('the')
    .child('image_filejpg');

ref.putFile(imageFile);
// or ref.putData(Uint8List.fromList(imageData));

var url = await ref.getDownloadURL() as String;

or

var url = Uri.parse(await ref.getDownloadURL() as String);
like image 132
Günter Zöchbauer Avatar answered Oct 18 '22 01:10

Günter Zöchbauer