I´m trying to make an app to upload images and then fetch them to another screen following a tutorial. However, I haven´t been able to complete a line because it won´t find getDownloadUrl.
I investigated, and I know it is deprecated, but I can´t find a way to put it to complete the line.
private void uploadFiles(){
if (mImageUri != null){
StorageReference fileReference = mStorageRef.child(System.currentTimeMillis() + "." + getFileExtension(mImageUri));
mUploadTask = fileReference.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
pBar.setProgress(0);
}
}, 5000);
Toast.makeText(enviarEvidencias.this, "Subida Exitosa", Toast.LENGTH_LONG).show();
**upload upload = new upload(text.getText().toString().trim(),
taskSnapshot.getDownloadUrl.toString());**
String uploadId = mDatabaseRef.push().getKey();
mDatabaseRef.child(uploadId).setValue(upload);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(enviarEvidencias.this, e.getMessage(), 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());
pBar.setProgress((int) progress);
}
});
}else{
Toast.makeText(this, "No file selected", Toast.LENGTH_SHORT).show();
}
}