java - Firebase下载到内存后如何访问文件?
问题描述
我已经实现了以下代码,用于将 Firebase 存储文件下载到内存。因此,下一步是我要访问该文件。在这种情况下,我怎样才能做到这一点?
//Download to memory
public void downloadToMemory(StorageReference sRefChild, String selectedFile)
{
final long ONE_MEGABYTE = 1024 * 1024 *5;
sRefChild.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
System.out.println("On success!");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
System.out.println("Handle failure...");
}
});
解决方案
您想如何访问该文件?默认情况下,您可以new ByteArrayOutputStream()
用作存储。
https://stackoverflow.com/a/17595282/6916890
推荐阅读
- cucumber-jvm - 哪个是 cucumber-jvm 并行版本、maven surefire 和编译器的正确组合,要配置为并行运行测试用例
- ruby - 用 Ruby 解释这种竞争条件
- python - 如何将行与 DataFrame 中的值组合合并
- nativescript - Nativescript RadCalendar 获得点击内联事件
- opengl - GL_TEXTURE_CUBE_MAP 的 glGetTexImage
- bash - 如何检查一组数字与另一组数字
- javascript - 如何使用 CSS 使用重叠元素掩盖文本的可见性
- r - 改进 R-shiny 代码的建议(我应该运行代码两次以在 R-Shiny 中绘制不同的结果吗?)
- python - 提取文本:在一个带有 Beautiful Soup 的元素之后
- javascript - Kafka Node High Level Producer 仅写入偶数分区