how can I download image on firebase storage?

后端 未结 5 533
难免孤独
难免孤独 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:37

    To download a file, first create a Cloud Storage reference to the file you want to download.

    You can create a reference by appending child paths to the storage root, or you can create a reference from an existing gs:// or https:// URL referencing an object in Cloud Storage.

    // Create a storage reference from our app
    StorageReference storageRef = storage.getReference();
    
    // Create a reference with an initial file path and name
    StorageReference pathReference = storageRef.child("images/stars.jpg");
    

    images is the child of root.

    storageRef.child("images/stars.jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener() {
        @Override
        public void onSuccess(Uri uri) {
            // Got the download URL for 'users/me/profile.png'
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            // Handle any errors
        }
    });
    

提交回复
热议问题