Dart 仅从ios将文件上载到firebase时出错

Dart 仅从ios将文件上载到firebase时出错,dart,flutter,Dart,Flutter,尝试将图像上载到firebase存储时,我遇到以下错误: PlatformException(错误-13000,FIRStorageErrorDomain,发生未知错误,请检查服务器响应。) 奇怪的是,当我从android设备调用完全相同的函数时,我没有遇到这个错误。当我调用函数时: Future saveToStorage(File image) async { FirebaseStorage.instance.setMaxOperationRetryTimeMillis(10); s

尝试将图像上载到firebase存储时,我遇到以下错误:

PlatformException(错误-13000,FIRStorageErrorDomain,发生未知错误,请检查服务器响应。)

奇怪的是,当我从android设备调用完全相同的函数时,我没有遇到这个错误。当我调用函数时:

Future saveToStorage(File image) async {
  FirebaseStorage.instance.setMaxOperationRetryTimeMillis(10);
  storageReference = FirebaseStorage.instance.ref().child("AllUsers").child(uuid).child(imageFileName);

  final StorageUploadTask uploadTask = storageReference.putFile(image, const StorageMetadata(contentLanguage: "en"));
  await uploadTask.future.then( (UploadTaskSnapshot snapshot) { // hangs at this line
    if (snapshot.downloadUrl != null) {
      String downloadUrl = snapshot.downloadUrl.toString();
      final fireImage = new FireImage(imageFileName, currentDateTime, imageCount, downloadUrl);
      storage.deleteImageFile(imageFileName);
      saveToDatabase(fireImage);
      instance.setInt("ImageCount", imageCount + 1);
    } else {
      saveFile(image);
    }
  })
}
代码挂起在
等待上载task.future.then(etc
然后给出上述错误

更新1: 我也注意到了这个错误
[Generic]创建一个未知类型的图像格式是一个错误

更新2: 现在出现此错误:

  [] __nwlog_err_simulate_crash_libsystem libsystem simulate crash unavailable "libsystem_network.dylib: nw_host_stats_add_src :: received error for SRC_ADDED: [22] Invalid argument"
  [] nw_host_stats_add_src received error for SRC_ADDED: [22] Invalid argument, dumping backtrace:
  [x86_64] libnetcore-856.1.8
  0   libsystem_network.dylib             0x0000000115e4480e __nw_create_backtrace_string + 123
  1   libsystem_network.dylib             0x0000000115e5b358 nw_get_host_stats + 1083
  2   libnetwork.dylib                    0x000000011712aca9 nw_endpoint_resolver_start_next_child + 1382
  3   libdispatch.dylib                   0x0000000115bcc810 _dispatch_call_block_and_release + 12
  4   libdispatch.dylib                   0x0000000115bee12e _dispatch_client_callout + 8
  5   libdispatch.dylib                   0x0000000115bd3523 _dispatch_queue_serial_drain + 1018
  6   libdispatch.dylib                   0x0000000115bd3cf3 _dispatch_queue_invoke + 1118
  7   libdispatch.dylib                   0x0000000115bd5a0e _dispatch_root_queue_drain + 506
  8   libdispatch.dylib                   0x0000000115bd57b4 _dispatch_worker_thread3 + 113
  9   libsystem_pthrea

有人知道我为什么只在ios上出现这个错误吗?

我解决这个问题的方法是调用
final url=(wait uploadTask.future)。downloadUrl;
并检查downloadUrl是否不为null,这样调用。如果你能看到其他解决方法,那就太好了

Future saveToStorage(File image) async {
  FirebaseStorage.instance.setMaxUploadRetryTimeMillis(100)
  final StorageReference ref = FirebaseStorage.instance.ref().child("AllUsers").child(uuid).child(imageFileName);
  final StorageUploadTask uploadTask = ref.putFile(image, const StorageMetadata(contentLanguage: "en"));
  print("Saving to storage here with file: $image");
  final url = (await uploadTask.future).downloadUrl;
    print("uploading image: $image");
    if (url != null) {
      print("got here with url");
      String downloadUrl = url.toString();
      final fireImage = new FireImage(imageFileName, currentDateTime, imageCount, downloadUrl);
      storage.deleteImageFile(imageFileName);
      print('download URL: $downloadUrl');
      saveToDatabase(fireImage);
      instance.setInt("ImageCount", imageCount + 1);
    } else {
      print("got here without url");
      saveFile(image);
    }
}