How to get full downloadUrl from UploadTaskSnapshot in Flutter?

前端 未结 4 589
感情败类
感情败类 2020-11-29 11:59

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

H

4条回答
  •  一整个雨季
    2020-11-29 12:53

    From my this answer,

    The latest version of plugin doesn't let you use task.future() anymore and in the documentation they say to use lastSnapshot which didn't work for me.

    So, I used onComplete. Here is the working solution:

    StorageUploadTask uploadTask = storageRef.putFile(yourFile);
    StorageTaskSnapshot storageTaskSnapshot = await uploadTask.onComplete;
    String downloadUrl = await storageTaskSnapshot.ref.getDownloadURL();
    

提交回复
热议问题