有没有什么方法可以使用Java api将图像文件存储在Firebase中?我可以使用Java API将图像文件存储在firebase中
8
A
回答
11
尝试使用这段代码:
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);
和检索
public Bitmap stringToBitMap(String encodedString){
try {
byte [] encodeByte=Base64.decode(encodedString,Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
return bitmap;
} catch(Exception e) {
e.getMessage();
return null;
}
}
+3
如何从imageFile字符串显示图像? – 2014-10-30 23:16:01
+3
以下内容可帮助您将编码的字符串显示为位图。 byte [] decodedString = Base64.decode(imageFileString,Base64.DEFAULT); 位图位图= BitmapFactory.decodeByteArray(decodedString,0,decodedString.length); imageView.setImageBitmap(bitmap); – ernestkamara 2016-06-12 11:57:06
相关问题
- 1. 我可以使用imgaeButton将图像上传到firebase存储
- 2. 可以将zip文件和图像存储在AppFabric缓存中
- 3. 从Firebase存储api检索图像
- 4. 使用身份验证ID将图像存储在Firebase中 - Xamarin
- 5. openGraph API - 我如何在mysql中存储配置文件图像
- 6. 在RecyclerView中显示Firebase存储图像
- 7. 我在哪里可以将默认图像存储在android
- 8. 我可以使用apache poi将图像保存在excel中吗?
- 9. Firebase iOS存储图像
- 10. Firebase存储图像下载
- 11. 使用Firebase RemoteConfig来存储API密钥可以吗?
- 12. 我可以在新的Azure文件存储中使用DFS
- 13. 我可以直接使用URL将图像下载到某个云存储中
- 14. 我可以将数据存储在PHP文件中吗?
- 15. 如何将Firebase存储图像与Google Cloud Vision API配合使用?
- 16. 显示存储在Firebase存储中的Firebase数据库中的图像
- 17. 在Firebase存储中上传PDF文件
- 18. 使用Java获取存储在PNG图像中的文本
- 19. 在WebApplication文件夹中存储图像
- 20. 如何使用SQL将图像存储到文件中?
- 21. 我可以使用Firebase存储服务AMP页面吗?
- 22. J2ME将图像存储到文件
- 23. 使用Java API将云存储文件移动到不同存储区
- 24. 我可以将文本文件存储在图像的EXIF数据中的压缩包中吗?
- 25. 我可以将HTML文件存储在drawable folde中,并将它们用于webview
- 26. 是否可以将图像存储在Flash的SharedObject中?
- 27. 将图像保存在Azure存储中
- 28. 将图片有效存储在Firebase存储中?
- 29. 我如何将fileReader之后的图像上传到firebase存储
- 30. 我可以将文件存储在iPhone的文件系统中吗?
如何在转换回位图? – 2014-10-30 23:16:29
@Binghammer很简单。 byte [] imageAsBytes = Base64.decode(imageFile,Base64.DEFAULT); Bitmap bmp = BitmapFactory.decodeByteArray(imageAsBytes,0,imageAsBytes.length); – skabir 2014-11-03 02:39:16
* Firebase刚发布了一项名为[Firebase Storage]的新功能(https://firebase.google.com/docs/storage/)。这允许您将图像和其他非JSON数据上传到专用存储服务。我们强烈建议您使用它来存储图像,而不是将它们作为base64编码数据存储在JSON数据库中。* – 2016-05-20 04:27:16