【问题标题】:Can I store image files in firebase using Java API?我可以使用 Java API 将图像文件存储在 Firebase 中吗?
【发布时间】:2014-12-19 17:56:38
【问题描述】:

有没有办法使用Java api将图像文件存储在firebase中以用于android应用程序?

我已经阅读了这个帖子Can I store image files in firebase using Java API,但仍然没有答案。我知道它有一个官方的 api,这里称为 firepano 是链接 https://github.com/firebase/firepano 但它是用于 Javascript 库的。

有Java库的解决方案吗??

【问题讨论】:

标签: android firebase java


【解决方案1】:

我使用了这段代码,现在它可以工作了:

  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);     

【讨论】:

  • 听起来不错。不要忘记接受您的回答(这可能会在几天后被允许),以便清楚地表明问题已得到解决(并获得一些声誉积分)。
  • @FrankvanPuffelen 是否推荐?在 Firebase 中上传图片?它真的意味着以这种方式有用吗?还是直接上传到 S3 存储桶上会更可取?我将 firebase 用于购物清单应用程序,并且我想包括图像支持。这样问!
猜你喜欢
  • 2014-12-05
  • 2015-07-15
  • 1970-01-01
  • 1970-01-01
  • 2021-04-22
  • 1970-01-01
  • 2020-03-17
  • 2016-12-31
  • 2021-08-19
相关资源
最近更新 更多