Firebase函数可调用-图像作为参数 [英] Firebase functions callable - image as argument

查看:76
本文介绍了Firebase函数可调用-图像作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个firebase函数,该函数给出一些参数来创建带有标题等的"post".有没有一种方法可以将图像作为参数发送,然后可以由firebase函数进行处理,然后上载到firebase存储.

I have a firebase function which given some arguments creates a "post" with a title and the such. Is there a way to send an image as an argument which can then be processed by firebase functions and then upload to firebase storage.

我认为可以通过将文件/图像对象解码为base64字符串,然后将其作为参数发送来实现.如何将文件对象从html文件输入转换为base64?另一方面,firebase函数将如何知道该字符串是实际图像?如何分辨图像的大小?赋予Firebase 可调用函数的参数大小是否受到限制?

I think it is possible by decoding the file/image object to a base64 string which could be then sent as an argument. How would I convert the file object from html file input to base64? On the other side how would firebase functions know that the string is an actual image? How can I tell the size of the image? Is there a limit to the size of arguments given to a firebase callable function?

推荐答案

我放弃了这个问题,但后来在另一个项目中遇到了这个问题.因此,任何人都可以通过base 64字符串看到它.它具有限制,即图像不能大于10mb,但是比直接上传后尝试捕获"文件要容易得多.

I ditched this question but came across the problem later in a different project. So to anyone seeing it is possible through base 64 strings. It has the restraints that the image cannot be bigger than 10mb but it is easier than trying to "catch" the file after it being uploaded directly.

这是解决方案

这篇关于Firebase函数可调用-图像作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆