FormatException:flutter Firebase Cloud Functions 中的信封无效

Unn*_*nan 6 dart flutter

我正在尝试从我的 flutter 应用程序中调用 firebase 函数以在 firestore 中保存图像。

我正在使用以下代码上传我的图像数据,但我收到错误 FormatException: Invalid envelope

_image = image.readAsBytes();
CloudFunctions.instance.call(
    functionName: 'updateUserImg',
    parameters: <String, dynamic>{
      'img':_image,
    },
  );
Run Code Online (Sandbox Code Playgroud)

我的云功能甚至没有被调用,似乎我以错误的格式发送数据。

我该如何解决这个问题?

谢谢。

Vns*_*tya 3

当您的请求超时时,就会发生这种情况。确保您有有效的互联网连接。如果通过 LAN 使用模拟器,请确保按如下方式指定来源。

cloudFunctions.useFunctionsEmulator(
        origin: "http://192.168.31.107:5001");
Run Code Online (Sandbox Code Playgroud)

代替

_cloudFunctions.useFunctionsEmulator(
        origin: "192.168.31.107:5001");
Run Code Online (Sandbox Code Playgroud)