Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormatException: Invalid envelope in flutter Firebase Cloud Functions

Tags:

flutter

dart

I'm trying to call firebase functions from my flutter application for saving an image in firestore.

I am using the following code to upload my image data, But i'm receiving the error FormatException: Invalid envelope

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

My cloud function is not even getting called, seems like i'm sending the data in wrong format.

How I can fix this issue?

Thanks.

like image 210
Unnikrishnan Avatar asked May 01 '19 13:05

Unnikrishnan


1 Answers

This happens when your request times out. Make sure you have an active internet connection. In case of using an emulator over LAN, make sure you specify origin as follows.

cloudFunctions.useFunctionsEmulator(
        origin: "http://192.168.31.107:5001");

instead of

_cloudFunctions.useFunctionsEmulator(
        origin: "192.168.31.107:5001");
like image 96
Vns Aditya Avatar answered Nov 15 '22 04:11

Vns Aditya