我的FirebaseStorage方法是';不要在颤栗中奔跑。在“firebase”存储之后:^4.0.0` 我的问题

我的FirebaseStorage方法是';不要在颤栗中奔跑。在“firebase”存储之后:^4.0.0` 我的问题,firebase,flutter,dart,google-cloud-firestore,firebase-storage,Firebase,Flutter,Dart,Google Cloud Firestore,Firebase Storage,有人能帮我吗?我正在尝试将图像发送到firebase存储,然后检索下载URL并保存到firebasefirestore。但是我的FirebaseStorage方法没有运行 在firebase存储:^4.0.0更新后发生 StorageReference storageRef = storage.getReference(); MyFirebaseStorage().ref().child('path).putFile()方法未运行 这是我的密码 我有这些台词 我也改变了firebase存储

有人能帮我吗?我正在尝试将图像发送到firebase存储,然后检索下载URL并保存到firebasefirestore。但是我的FirebaseStorage方法没有运行

在firebase存储:^4.0.0更新后发生

StorageReference storageRef = storage.getReference();
My
FirebaseStorage().ref().child('path).putFile()
方法未运行

这是我的密码
我有这些台词


我也改变了firebase存储的规则
我可以看到您正在使用.ref()来获取引用。 检查,您可以看到使用的是getReference()

因此,最好按照文档中的说明设置存储引用。此外,上载文件的代码如下所示:

Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
StorageReference riversRef = storageRef.child("images/"+file.getLastPathSegment());
uploadTask = riversRef.putFile(file);

请务必阅读我写的代码。它在flutter中,您的答案是JAVA。此外,对于颤振的
FirebaseStorage()
,也没有
getReference()
Future<dynamic> sendData(SearchTileModel st, List<File> data) async {
 bool completed = false;
 CollectionReference _collec = _firestore.collection('Accounts Posts');
 List<String> _imageUrls = [];
 print(data.length);
 data.length > 0
     ? data.asMap().forEach((
         index,
         element,
       ) async {
         print(index);
         print(element);
         String downloadUrl;
///////  HERE this code doesn't get called up  ////////////
         StorageTaskSnapshot snapshot = await FirebaseStorage()
             .ref()
             .child("Accounts Posts/Images/${index}")
             .putFile(element)
             .onComplete
             .then((value) {
           downloadUrl = value.ref.getDownloadURL().toString();
           return;
         });
         print(downloadUrl);
         print(snapshot);
         print(snapshot.error);
         if (snapshot.error == null) {
           await snapshot.ref
               .getDownloadURL()
               .then((value) => downloadUrl = value.toString());
           print(downloadUrl);
           _imageUrls.insert(index, downloadUrl);
           if (st.images.length == _imageUrls.length) {
             SearchTileModel newModel = st;
             newModel.images = _imageUrls;
             await _collec
                 .doc('${newModel.placeName} : name')
                .set(
                  st.toJson(),
                  SetOptions(mergeFields: [
                    'images',
                  ]),
                )
                .whenComplete(() {
              return completed = true;
            }).catchError((onError) {
              print('${onError.toString()}');
              completed = false;
            });
          }
        } else {
          completed = false;
          print('Error from image repo ${snapshot.error.toString()}');
          throw ('This file is not an image');
        }
      })
    : print('No Images Selected');
if (data.length == 0) {
  SearchTileModel newModel = st;
  newModel.images = _imageUrls;
  await _collec
      .doc('${newModel.placeName} : name')
      .set(
        st.toJson(),
        SetOptions(mergeFields: [
          'images',
        ]),
      )
      .whenComplete(() {
    return completed = true;
  }).catchError((onError) {
    print('${onError.toString()}');
    completed = false;
  });
}
return completed;
}
  I/flutter (14005): true
  I/flutter (14005): redtfgn
  I/flutter (14005): File: 
  '/storage/emulated/0/Android/data/com.example.medium/files/Pictures/scaled_ec614e8a-0522-4cae-97be- 
  3ed50356de9c3343447263121135351.jpg'
  I/flutter (14005): 1
  I/flutter (14005): running
  I/flutter (14005): 0
  I/flutter (14005): File: 
  '/storage/emulated/0/Android/data/com.example.medium/files/Pictures/scaled_ec614e8a-0522-4cae-97be- 
  3ed50356de9c3343447263121135351.jpg'
  I/flutter (14005): Till Here the code is Running
I/BiChannelGoogleApi(17801): [FirebaseAuth: ] getGoogleApiForMethod() 
returned Gms: com.google.firebase.auth.api.internal.zzaq@cdf79f2
E/StorageUtil(17801): error getting token 
java.util.concurrent.TimeoutException: Timed out waiting for Task
D/NetworkSecurityConfig(17801): No Network Security Config specified, using 
platform default
W/NetworkRequest(17801): no auth token for request
rules_version = '2';
service firebase.storage {
 match /b/{bucket}/o {
   match /{allPaths=**} {
     allow read, write ;
   }
 }
}
StorageReference storageRef = storage.getReference();
Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
StorageReference riversRef = storageRef.child("images/"+file.getLastPathSegment());
uploadTask = riversRef.putFile(file);