我可以使用Java API将图像文件存储在Firebase中吗? [英] Can I store image files in firebase using Java API?
本文介绍了我可以使用Java API将图像文件存储在Firebase中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经读过这个线程我可以使用Java API将图像文件存储在firebase中,但仍然没有回答。我知道有一个官方API,称为firepano这里是链接 https://github.com/firebase / firepano ,但它是用于Javascript库的。
是否有任何针对Java库的解决方案?
$ p $
位图bmp = BitmapFactory decodeResource(getResources(),
R.drawable.chicken); //你的图像
ByteArrayOutputStream bYtE = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG,100,bYtE);
bmp.recycle();
byte [] byteArray = bYtE.toByteArray();
String imageFile = Base64.encodeToString(byteArray,Base64.DEFAULT);
Is there any way to store image files in firebase using Java api to be used for android application?
I have read this thread Can I store image files in firebase using Java API and still there is no answer. I know that there is an official api for it, called firepano here is the link https://github.com/firebase/firepano but it is for Javascript library.
is there any solution for Java library??
解决方案
I used this code and now it's working:
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.chicken);//your image
ByteArrayOutputStream bYtE = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, bYtE);
bmp.recycle();
byte[] byteArray = bYtE.toByteArray();
String imageFile = Base64.encodeToString(byteArray, Base64.DEFAULT);
这篇关于我可以使用Java API将图像文件存储在Firebase中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文