flutter - 从上传的文件中获取 DownloadURL
问题描述
我想知道getDownloadURL()
当我上传文件时如何获取。我想上传一个文件并获取该文件的downloadURL,然后将其存储到数据库中。你能举例说明如何在一个函数中做到这一点吗?
解决方案
String filePath = "videoTitle.mp4";
StorageReference ref = FirebaseStorage.instance.ref().child(filePath);
StorageUploadTask uploadTask =
ref.putFile(video, StorageMetadata(contentType: "video/mp4"));
await uploadTask.onComplete;
if (uploadTask.isComplete) {
String downloadUrl = await ref.getDownloadURL();
return downloadUrl;
}
推荐阅读
- javascript - 正常吗,redux 创建这么多存储?
- cobalt - Cobalt 应用程序支持 Android 触摸屏设备
- python-3.x - Pandas DataFrame - 生成半年期指数
- r - 如何阻止 R 中的 stat_density2d 绘制在边界线的左侧?
- cplex - OPL_ 对元素求和直到某个元素
- eclipse - 如何在 Eclipse 2021-06 JRE x86_64_16.0.2 中使用 JavaFX
- python - 如何在 /usr/bin/python 上安装 python 3.8.12?
- sql-server - Docker 中的 SQL Server 命名实例
- python - 强化学习与超级马里奥不学习
- amazon-web-services - 我可以在同一个 beanstalk 环境中使用单独的应用程序包发布 2 个站点吗?