【发布时间】:2019-12-29 02:39:47
【问题描述】:
发生 Firebase 存储异常。据说该对象不存在但是当我检查调试窗口和 Firebase 控制台时,它就在那里。请帮帮我。
我尝试了“Glide”库,但“Using”方法不可用。我也尝试使用“FirebaseImageLoader”和“load”方法,但失败了。我想在不使用“Glide”库的情况下将图像连接到 ImageView。
StorageReference storageReference = FirebaseStorage.getInstance().getReference();
StorageReference photoReference= storageReference.child("Image/"+fileName);
final long ONE_MEGABYTE = 1024 * 1024;
photoReference.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
imageView.setImageBitmap(bmp);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Toast.makeText(getApplicationContext(), "No Such file or Path found!!", Toast.LENGTH_LONG).show();
}
});
“photoReference”的值(url)与 Firebase 控制台中我的图像的“存储位置”相同。那么为什么会出现对象不存在的异常呢?我很好奇。
【问题讨论】:
-
只需传递 url 即可滑动