I have written an app which lets the user upload an image with handwritten text and now he/she should receive the extracted text as 'normal' (digital) text.
Currently, I upload the image to a google cloud bucket, which then triggers a cloud function, that calls the vision api. The vision api then returns a JSON
result inside of the cloud function.
Now my question: How can I send the JSON result back to the client?
- I've tried FCM but the JSON response of the
vision api
is more than 4000 bytes, so the message fails to send. (I also need the coordinates of the recognized text). Getting the following error:
...
errorInfo: {
code: 'messaging/invalid-argument',
message: 'Request contains an invalid argument.'
}
- I've heared of PubSub but as they described here , it is not a good use for service-to-client communication. Or is it an option never the less?
How can I send the "big" result from my cloud function back to the client?
Any help is greatly appreciated! Thanks for your time, if anything is unclear or missing I'm happy to add the information asap.
CodePudding user response:
Don't use FCM to send the actual payload of the vision API to the user. Instead, store the payload in Cloud Storage or a cloud database (such as Firebase's Firestore or Realtime Database) and send the location to the user through FCM in a data property. Your application code can then take that data property, and read the actual API response when the user is ready for it.