【问题标题】:StorageException has occurred. Object does not exist at location?发生了 StorageException。对象在该位置不存在?
【发布时间】:2018-04-15 17:34:31
【问题描述】:

storageReference=storage.getInstance().getReference("images/"+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);
        }
    });

我该如何解决这个问题?

【问题讨论】:

    标签: android firebase


    【解决方案1】:

    查看reference url 并获取 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");
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2021-12-29
      • 2023-03-10
      • 2020-04-17
      • 2019-04-07
      • 2020-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-13
      相关资源
      最近更新 更多