StorageException已发生。对象在位置不存在?

时间:2018-04-15 17:34:32

标签: android firebase

storageReference = storage.getInstance()getReference( “图像/” + homeClass.getHomeId()+ “JPG”);

     final long ONE_MEGABYTE = 1024 * 1024;
     storageReference.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
        @Override
        public void onSuccess(byte[] bytes) {
            Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);

                imageView.setImageBitmap(Bitmap.createScaledBitmap(bmp,imageView.getWidth(),
                    imageView.getHeight(), false));
            holder.progressBar.setVisibility(View.GONE);
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // Handle any errors
            Toast.makeText(c.getApplicationContext(),"Unable to show picture",Toast.LENGTH_SHORT);
            holder.progressBar.setVisibility(View.GONE);
        }
    });

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

查看reference网址并获取imageRef

// Create a storage reference from our app

StorageReference storageRef = storage.getReference();

// Create a child reference
// imagesRef now points to "images"

StorageReference imagesRef = storageRef.child("images");

// Child references can also take paths
// spaceRef now points to "images/space.jpg
// imagesRef still points to "images"

StorageReference spaceRef = storageRef.child("images/"+homeClass.getHomeId()+".jpg");

我希望这会对你有所帮助。