请帮助我将https:// URL保存到特定用户下的Firebase数据库中。这是代码段:
if(filePath != null)
{
FirebaseStorage storage = FirebaseStorage.getInstance();
String userUid = FirebaseAuth.getInstance().getCurrentUser().getUid();
/*to be deleted - tests to save the profile image under wardrobe child*/
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
final DatabaseReference databaseReference = firebaseDatabase.getReference(userUid).child("WARDROBE");
//end of tobedeleted
//StorageReference storageRef = storage.getReference(userUid).child("images/" + filePath.getLastPathSegment());
StorageReference storageRef = storage.getReference(userUid).child("images/" + "profilePicture");
UploadTask uploadTask = storageRef.putFile(filePath);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
databaseReference.push().setValue(taskSnapshot.getStorage().getDownloadUrl().toString());//to be deleted
progressDialog.dismiss();
Toast.makeText(CropProfilePicture.this, "Uploaded", Toast.LENGTH_SHORT).show();
finish();
startActivity(new Intent(CropProfilePicture.this, Profile.class));
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(CropProfilePicture.this, "Failed "+e.getMessage(), Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
progressDialog.setMessage("Uploading...");
}
});
保存的URL不是https:// URL,而是此
:"com.google.android.gms.tasks.zzu@367c82"