对于我在聊天室relatie
中发送的每张图片,这都会返回我
以下是我的代码:
com.google.android.gms.tasks.zzu@d55ef5
需要帮助..提前感谢
答案 0 :(得分:0)
您可以改用Task<Uri>
,尝试一下。
不建议使用此getMetadata().getReference().getDownloadUrl()
,建议您阅读此Upload-files firebase
photoReference.putFile(uriImagen).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Task<Uri> downloadUri = taskSnapshot.getStorage().getDownloadUrl();
if(downloadUri.isSuccessful()){
String urlPhoto = downloadUri.getResult().toString();
Log.v("Url de la foto", urlPhoto);
Message m = new Message(tvName.getText().toString() + " te ha enviado una foto", urlPhoto, tvName.getText().toString(), "", "2", "00:00");
databaseReference.push().setValue(m);
}}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
//Do whatever you want
}
});
答案 1 :(得分:0)
尝试此代码:
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Task<Uri> downloadUrl = taskSnapshot.getStorage().getDownloadUrl();
downloadUrl.addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
Log.v(TAG, "Media is uploaded");
String downloadURL = "https://" + task.getResult().getEncodedAuthority()
+ task.getResult().getEncodedPath()
+ "?alt=media&token="
+ task.getResult().getQueryParameters("token").get(0);
Log.v(TAG, "downloadURL: " + downloadURL);
//save your downloadURL
}
});
}