将图像上传到Firebase存储

时间:2019-09-05 14:46:10

标签: firebase flutter dart firebase-storage

我上传的图片放在Firebase存储中看不到了

Future uploadPic(BuildContext context) async {
    String fileName = basename(_image.path);
    StorageReference firebaseStorageRef = FirebaseStorage.instance.ref().child(fileName);
    StorageUploadTask uploadTask = firebaseStorageRef.putFile(_image);
    StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete;

    setState(() {
        print("Profile picture uploaded");
        Scaffold.of(context).showSnackBar(SnackBar(content: Text('Profile picture uploaded')));
    });
}

0 个答案:

没有答案