有沒有什麼方法可以使用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. Firebase存儲圖像檢索
- 8. Firebase iOS存儲圖像
- 9. 我在哪裏可以將默認圖像存儲在android
- 10. 使用Firebase RemoteConfig來存儲API密鑰可以嗎?
- 11. Firebase存儲圖像下載
- 12. 我可以使用apache poi將圖像保存在excel中嗎?
- 13. 在將圖像上傳到Firebase存儲之前壓縮圖像
- 14. 我可以在新的Azure文件存儲中使用DFS
- 15. 將圖像保存爲存儲文件
- 16. 顯示存儲在Firebase存儲中的Firebase數據庫中的圖像
- 17. 在Firebase存儲中上傳PDF文件
- 18. 如何將Firebase存儲圖像與Google Cloud Vision API配合使用?
- 19. 我可以將數據存儲在PHP文件中嗎?
- 20. 我可以直接使用URL將圖像下載到某個雲存儲中
- 21. 我可以使用Firebase的REST API來使用事件嗎?
- 22. 可以使用對象存儲GE來存儲圖像嗎?
- 23. 我可以在哪裏存儲自定義控件的圖像?
- 24. 使用dropzonejs將圖像上傳到Firebase存儲?
- 25. 我可以使用Firebase存儲服務AMP頁面嗎?
- 26. 使用ArrayList在java中存儲文件
- 27. 使用Firebase存儲上傳文件
- 28. 將圖像存儲在我的項目的圖像文件夾中的困難
- 29. 我應該在哪裏存儲圖像,以便我可以與他們一起使用iTunes文件共享?
- 30. 在IndexedDB中存儲圖像文件
如何在轉換回位圖? – 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