我试图从Facebook获取个人资料图片,然后将其存储在firebase存储中。我能够获取个人资料图片Uri,但是,我无法将图片上传到firebase存储。 firebase返回的错误消息是:"发生未知错误。"在调试之后,我还在抛出的异常对象中看到了这条消息," java.io.FileNotFoundException:没有内容提供者:https://graph.facebook.com ..."我在网上搜索过,但我找不到任何有用的东西。值得注意的是,我能够将其他图片上传到存储,所以我相信语法是正确的。我试图存储fb个人资料图片时遇到问题。任何形式的帮助将不胜感激!
private void saveFbData() {
FirebaseUser user = mAuth.getCurrentUser();
final String id = user.getUid();
Uri fbUserProfilePictureUri = Profile.getCurrentProfile().getProfilePictureUri(125, 125);
String firstName = Profile.getCurrentProfile().getFirstName();
String lastName = Profile.getCurrentProfile().getLastName();
StorageReference filepath = mStorage.child(id).child("ProfilePicture");
filepath.putFile(fbUserProfilePictureUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getActivity(), "Successfully stored Profile Picture", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_LONG).show();
}
});
UserProfileData uProfileData = new UserProfileData(firstName, lastName);
mDatabase.child("UserProfileData").child(id).setValue(uProfileData, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
return;
}
});
}