![](/img/trans.png)
[英]Want to fetch current user photourl and name firestore react Native
[英]How can I add a photoUrl to the current user?
在我的应用程序中,我选择了一个带有图像选择器 dart 包( pub.dev 链接)的图像。 然后我将此图像上传到 Cloud Storage。 我也可以从数据库中获取 url,但是如何将此 url 作为 photoUrl 添加到当前用户? 如何更新 firebase 用户?
图像选择器代码:
getImage(BuildContext context) async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (image != null) {
cropImage(image);
_showDialog(context);
}
setState(() {
_image = image;
print("Image Path $_image");
});
}
上传代码:
uploadPic(BuildContext context) async {
String fileName = basename(_image.path);
StorageReference firebaseStorageRef =
FirebaseStorage.instance.ref().child("profilbilder/" + fileName);
StorageUploadTask uploadTask = firebaseStorageRef.putFile(_image);
StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete;
// Photo URL
var dowurl = await (await uploadTask.onComplete).ref.getDownloadURL();
String url = dowurl;
setState(() {
print("Profile Picture uploaded");
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.