Retrieving Download URL from Firebase:
In Firebase, getting the download URL for an uploaded file requires a different approach than using the getTask().getResult() method.
To obtain the download URL, you must utilize the addOnSuccessListener() method on the UploadTask. This method accepts a listener that handles the success scenario after a successful upload. Within the listener, invoke storageRef.getDownloadUrl().addOnSuccessListener() to retrieve the download URL as a Uri.
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { String url = uri.toString(); // Utilize the download URL for further operations } }); } });
The above is the detailed content of How to Retrieve a Firebase Storage Download URL?. For more information, please follow other related articles on the PHP Chinese website!