Firebase Storage with Flutter 未获取文件类型

问题描述 投票:0回答:1

我从 Flutter 项目将图像上传到 Fireabse Storage,这是我的代码。

return storageRef
          .ref(profileDir)
          .child("${DateTime.now().millisecondsSinceEpoch}.png")
          .putFile(profilePhoto)
          .then((taskSnapshot) => taskSnapshot.ref.getDownloadURL());

但是在firebase Storage中,类型没有出现,我怎样才能显示类型。

flutter google-cloud-firestore storage
1个回答
0
投票

您应该能够设置文件的元数据。如果没有这个,文件存储默认为

application/octet-stream
。例如:

.putFile(profilePhoto, SettableMetadata(contentType: 'image/png'))
© www.soinside.com 2019 - 2024. All rights reserved.