John 6:48 I am the bread of life. 49 Your fathers ate the manna in the wilderness, and are dead. 50 This is the bread which comes down from heaven, that one may eat of it and not die. 51 I am the living bread which came down from heaven. If anyone eats of this bread, he will live forever; and the bread that I shall give is My flesh, which I shall give for the life of the world. 52 The Jews therefore quarreled among themselves, saying, How can this Man give us His flesh to eat? 53 Then Jesus said to them, Most assuredly, I say to you, unless you eat the flesh of the Son of Man and drink His blood, you have no life in you. 54 Whoever eats My flesh and drinks My blood has eternal life, and I will raise him up at the last day. 55 For My flesh is food indeed,[h] and My blood is drink indeed. 56 He who eats My flesh and drinks My blood abides in Me, and I in him. 57 As the living Father sent Me, and I live because of the Father, so he who feeds on Me will live because of Me. 58 This is the bread which came down from heavennot as your fathers ate the manna, and are dead. He who eats this bread will live forever."
59 These things He said in the synagogue as He taught in Capernaum.
... around Passover, exactly a year before the Last Supper.
Much of the Bible is alegorical. "I am the door" is a good example.
That's metaphor, not allegory. "Eat my flesh and drink my blood" is not metaphor, and it's not allegory either.
And don't forget what came next:
John 6:60 On hearing it, many of his disciples said, "This is a hard teaching. Who can accept it?"
61 Aware that his disciples were grumbling about this, Jesus said to them, "Does this offend you? 62 What if you see the Son of Man ascend to where he was before! 63 The Spirit gives life; the flesh counts for nothing. The words I have spoken to you are spirit[e] and they are life. 64 Yet there are some of you who do not believe." For Jesus had known from the beginning which of them did not believe and who would betray him. 65 He went on to say, "This is why I told you that no one can come to me unless the Father has enabled him."
66 From this time many of his disciples turned back and no longer followed him.
"That's metaphor, not allegory. "Eat my flesh and drink my blood" is not metaphor, and it's not allegory either."
And believe me, it's not literal, either.