在创建用户配置文件的时候,我试图为我的用户使用SetPhotori,我使用两个seperate方法首先上传,然后获取url,这两个方法都是从“CreateUserWithEmailandPassword”方法中调用的,但我得到了这个错误消息:com.google.firebase.storage.StorageException:Object不存在。
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(SignupActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Toast.makeText(SignupActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(SignupActivity.this, "Authentication failed." + task.getException(),
Toast.LENGTH_SHORT).show();
} else {
user = auth.getCurrentUser();
if(user!=null){
uploadImage();
getImageUrl();
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setPhotoUri(downloadUri)
.setDisplayName(displayNameString).build();
user.updateProfile(profileUpdates);
FirebaseAuth.getInstance().signOut();
Intent intent = new Intent(SignupActivity.this, LoginActivity.class);
intent.putExtra("Email",user.getEmail());
if (user.getPhotoUrl()!=null){
intent.putExtra("Image",user.getPhotoUrl().toString());
}
startActivity(intent);
Toast.makeText(SignupActivity.this, "Verifique su contraseña",
Toast.LENGTH_SHORT).show();
}
}
}
});
private void uploadImage() {
if(filePath != null)
{
ref = storageReference.child("UserProfileImages/"+user.getEmail() );
ref.putFile(filePath); //I checked on my project and the file is successfully uploaded.
}
}
//如果我使用ref.toString(),结果与项目中文件的路径完全匹配
public void getImageUrl (){
ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
downloadUri = uri;// The string(file link) that I need to use the setPhotoUri for my user.
Log.i("Class","Photo "+ downloadUri);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
Log.i("Class","an error occurred "+ exception.toString());
}
});
}
为了不接收此错误消息,需要首先上传文件,等待某个时间,直到文件存储完毕,然后获取下载URL。
我通过向ref.putfile()方法添加一个oncompletelistener来修复这个问题
问题内容: 因此,我在回答这个问题的同时一直在使用Python,但发现这是无效的: 由于 。但是,对于从对象继承的任何类,它都是有效的: 打印将按预期显示“ hello”。为什么会这样呢?在Python语言规范中,有哪些规定不能将属性分配给香草对象? 问题答案: 为了支持任意属性分配,对象需要一个:与对象关联的字典,可以在其中存储任意属性。否则,就无处放置新属性。 的实例object并没有随身携带
我有一个与我的CSS有关的div位置的问题。 我的父div设置为,子div设置为 但由于某些原因,子div显示在父div的边界下方和外部。。。 这是我的CSS: 超文本标记语言: 我提供了一个JSFiddle来向您展示它的实际操作: http://jsfiddle.net/j6VLc/1/ 在使用时,如何修复它以使子div位于父div内?
更新,存储FireBase中的映像
安装DevEco Studio后。我必须设置一个新项目,但是,显示以下错误 这里我无法设置HarmonyOS的SDK位置,如何设置SDK位置?
我已经尝试了StackOverflow上发布的所有解决方案,但我的问题没有在那里讨论,所以我提出了这个问题。在我的例子中,图像被上传到firebase存储桶中,但没有在firestore中插入新记录,因此发生了此错误。我的代码:- 存储数据函数如下所示:-
问题内容: 有没有办法在spring中将属性设置为类的对象,而不是类的实例?即 而不是 为您提供“ Foo”的实例,例如: 编辑:迄今为止最好的(可行的)解决方案-使用常规实例化并在setter中派生该类。在解决方案方面,我认为我们将其描述为“作弊”: 编辑:dtsazza的方法也可以。 编辑:pedromarce的方法也可以。 问题答案: 那应该工作。