namwa
namwa

Reputation: 45

Efficiency sending images as base64 string to Firebase Cloud Functions

I intend to upload an image together with name and email as a single transaction to a Firebase Cloud Function using HTTP POST. The Function will write details to Firestore database and store the image in Firebase Storage.

I thought about using Firebase Storage browser client API but because it's only a small avatar image and I want to keep client code thin (i.e GUI code only), I opted to use Cloud Function as a sole interface between my app and the backend.

If I send the image as a base64 encoded string, would there be any size limit to the payload and would there be any practical downside such as potential for timeouts?

Upvotes: 1

Views: 349

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317427

would there be any size limit to the payload

The payload size limit for Cloud Functions is 10MB and can't be exceeded.

would there be any practical downside such as potential for timeouts

There's always a chance for an HTTP request to fail due to a timeout or other network disturbance. If you want to work around that, you will need to implement some retry logic in your app.

Upvotes: 1

Related Questions