Compress request sent to Firebase function

As Firebase documentation states, there is a 10 MB limit on requests sent to Firebase functions from the frontend. Is there a way to compress the JSON data sent to the functions, to circumvent this limit. There are undocumented parameters that can be passed into the httpsCallable function, and I was wondering if perhaps a gzip or similar parameter could be passed in:

  var test = firebase
    .httpsCallable("test", { timeout: 360000, compresslevel=6, ... }); 

2 answers

  • answered 2020-09-30 01:33 Frank van Puffelen

    There is nothing built into the client-side or server-side Functions SDKs for that. If you're sending that much JSON in a single request, I'd recommend storing that JSON on another medium (like Cloud Storage) and just sending details of that location into Cloud Functions.

    That said, I'd imagine the Cloud Functions for Firebase folks would gladly take any PRs implement it. :)

  • answered 2020-09-30 03:24 Doug Stevenson

    There are not any special arguments that will compress the payload for you. But you are certainly free to compress the entire argument before you pass it to call() on the client, and decompress it as you receive it in the backend function. However, since callable functions only accept JSON as input, you will have to turn the compressed argument into a string as well before you pass it along, and that will add some size back to it.