How can `firebase.functions().httpsCallable` submit files to `functions.https.onCall`?

前端 未结 1 1104
面向向阳花
面向向阳花 2021-01-06 06:15

Background:

  1. We want to allow users to upload files onto our website
  2. The files need to be validated and modified before they are writt
相关标签:
1条回答
  • 2021-01-06 06:56

    That's not really an intended use case for callable functions. Callables are meant to send a JSON payload to the server, not a file. If you really want to send a (small) file to a function, you'll need to base64 encode it as a string, and put that string in the JSON payload, then decode it in the function.

    Instead, consider allowing the client to upload directly to storage, then use a function to validate it with a storage trigger, and delete it if it's not valid.

    0 讨论(0)
提交回复
热议问题