-1

I upload an image to Firebase Storage for profil_image, with this code


                StorageReference reference = storageReference.child("Profil_photo/"+ UUID.randomUUID().toString());

                reference.putBytes(dataarray).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                    @Override
                    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                        progressDialog.dismiss();
                        Toast.makeText(Register.this,"gambar berhasil di upload",Toast.LENGTH_SHORT).show();
                    }
                }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
                    @Override
                    public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
                        double progress = (100.0*snapshot.getBytesTransferred()/snapshot.getTotalByteCount());
                        progressDialog.setMessage("Proses Upload "+(int)progress + "%");
                    }
                });
            }

I am still a newbie, how to retrieve images that I can use in my home menu

I has try to use Uri downloadURL = tasksnapshot.getDownloadURL but i can't found getDownloadurl

AiHaQ
  • 105
  • 2
  • 7

1 Answers1

1

Use this

taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()

and then store the download URL to the database.

How to read

  • query database for store downloaded URL and use in view.
Hasan Khan
  • 554
  • 1
  • 7
  • 23