在Firebase存储上获取数据时出现错误。
我正在处理聊天项目,我想从Firebase Storage获取图像,我已经根据需要正确定义了我的StorageReference,并从中getDownloadUrl()
进行了定义,但仍然没有获得正确的
filePath.getDownloadUrl().toString()
中的问题无法正确获取数据网址,它给了我这样的字符串(“ com.google.android.gms.tasks.zzu@2e9f4dd8”)
StorageReference storageProfileImageReference = FirebaseStorage.getInstance().getReference().child("Profile Images");
if (resultCode == RESULT_OK) {
//Make child from Profile Images and named it with user id
final StorageReference filePath = storageProfileImageReference.child(mAuth.getCurrentUser().getUid()+".jpg");
filePath.putFile(result.getUri()).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()){
getUserDataReference.child("Image").setValue(filePath.getDownloadUrl().toString())
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(SettingActivity.this, "Image Saved!", Toast.LENGTH_SHORT).show();
}
});
}
else{
Toast.makeText(SettingActivity.this, "Error Occurred!, Try again ", Toast.LENGTH_SHORT).show();
}
}
});
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();