我可以储存的图像文件在火力使用Java API [英] Can I store image files in firebase using Java API

查看:141
本文介绍了我可以储存的图像文件在火力使用Java API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法来存储使用Java API中的火力点的图像文件?

编辑: 我得到了解决。转换的图像的Base64字符串,并推到火力点。

  BMP位=(位图)data.getExtras()获得(数据)。
ByteArrayOutputStream流=新ByteArrayOutputStream();
bmp.com preSS(Bitmap.Com pressFormat.PNG,100,流);
bmp.recycle();
字节[]的字节数组= stream.toByteArray();
字符串镜像文件= Base64.en codeToString(字节数组,Base64.DEFAULT);
 

解决方案

请尝试使用这段代码:

  BMP位= BitmapFactory.de codeResource(getResources(),R.drawable.chicken); //你的形象
ByteArrayOutputStream字节=新ByteArrayOutputStream();
bmp.com preSS(Bitmap.Com pressFormat.PNG,100字节);
bmp.recycle();
字节[]的字节数组= bYtE.toByteArray();
字符串镜像文件= Base64.en codeToString(字节数组,Base64.DEFAULT);
 

Is there any way to store image files in firebase using Java api?

Edit: I got the solution. Converted the image to Base64 string and pushed to firebase.

Bitmap bmp = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
bmp.recycle();
byte[] byteArray = stream.toByteArray();
String imageFile = Base64.encodeToString(byteArray, Base64.DEFAULT);

解决方案

Try using this snippet:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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