Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I store image files in firebase using Java API?

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??

like image 200
sasuri Avatar asked Dec 14 '22 19:12

sasuri


1 Answers

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);     
like image 142
sasuri Avatar answered Jan 05 '23 05:01

sasuri