how can I download image on firebase storage?

后端 未结 5 487
难免孤独
难免孤独 2021-01-06 14:53

I want to download image on firebase storage in android app.

this is my image

I try this but it is not working

storageR         


        
5条回答
  •  伪装坚强ぢ
    2021-01-06 15:19

    Try this


    // Create a storage reference from our app
    StorageReference storageRef = storage.getReference();
    
    // Or Create a reference to a file from a Google Cloud Storage URI
    StorageReference gsReference = 
        storage.getReferenceFromUrl("gs://bucket/images/stars.jpg");
    
    
    /*In this case we'll use this kind of reference*/
    //Download file in Memory
    StorageReference islandRef = storageRef.child("images/island.jpg");
    
    final long ONE_MEGABYTE = 1024 * 1024;
    islandRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new         
    OnSuccessListener() {
        @Override
        public void onSuccess(byte[] bytes) {
            // Data for "images/island.jpg" is returns, use this as needed
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // Handle any errors
        }
    });
    

    • For more details Download Files on Android

提交回复
热议问题