How to download images with specific size from firebase storage

前端 未结 2 1805
萌比男神i
萌比男神i 2021-01-14 02:39

I am using firebase storage in my android app to store images uploaded by users. all images uploaded are square in shape. I discovered that downloading this

2条回答
  •  我在风中等你
    2021-01-14 03:19

    Try downloading your image using the following commands:-

    StorageReference islandRef = storageRef.child("yourImage.jpg");
        // defines the specific size of your image
        final long ONE_MEGABYTE = 1024 * 1024;
        islandRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener() {
            @Override
            public void onSuccess(byte[] bytes) {
                // Data for "yourImage.jpg" is returns, use this as needed
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                // Handle any errors
            }
        });
    

提交回复
热议问题