我试图从facebook获得个人资料图片,然后将其存储在firebase存储。我能够获得个人资料图片Uri,但是,我无法将图片上传到firebase存储。firebase返回的错误消息是:"发生未知错误…"在调试之后,我还在抛出的异常对象"java.io. exe"中看到了这条消息。FileNotFoundException: No content provider: 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;
}
});
}
根据图形文档,您有一个无效的参数,请查看此