and-nd-firebase
and-nd-firebase copied to clipboard
How to get downloadUrls for Multiple files in firebase android?
storageReference = mRef.child("Images").child(mAuth.getCurrentUser().getUid()).child(image_name); UploadTask uploadTask = storageReference.putBytes(data); uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() { @Override public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception { return storageReference.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener<Uri>() { @Override public void onComplete(@NonNull Task<Uri> task) { if (task.isSuccessful()) { Uri downloadUri = task.getResult(); //It will return the downloadUrl; //If i tried to store them in the list storeImageUrls.add(downloadUri.toString()); // storeImageUrls is a list
}
}
}
//If i upload different images to the storage then different images get uploaded but getting only 1 url and it get stored in the list. So, if i upload 10 images, the images get uploaded but getting only 1 url stored like 10 images but same url for 10 images stored in the list.
I also has this condition