从Flutter中的Firebase存储获取下载URL [英] Get Download URL from Firebase Storage in Flutter

查看:73
本文介绍了从Flutter中的Firebase存储获取下载URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Flutter,我发现Flutter中有一个官方的Firebase Storage插件 firebase_storage
我有这样的存储引用:

I'm currently exploring Flutter, I found there is an official Firebase Storage plugin in Flutter firebase_storage I have storage reference like this one:

final StorageReference ref = FirebaseStorage.instance.ref().child("default.png");

但是没有方法可以从该StorageReference获取下载URL。

But there is no method to get download URL from that StorageReference.

推荐答案

如果上述解决方案无效,请尝试以下操作:

If the above solution doesn't work, try this:

Future<String> uploadImage(var imageFile ) async {
    StorageReference ref = storage.ref().child("/photo.jpg");
    StorageUploadTask uploadTask = ref.putFile(imageFile);

    var dowurl = await (await uploadTask.onComplete).ref.getDownloadURL();
    url = dowurl.toString();

    return url; 
}

这篇关于从Flutter中的Firebase存储获取下载URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆