Footage shared by the Detectives’ Endowment Association showed the cop standing outside the crime scene and taking notes near some broken glass — when a man holding two long white sticks crept up behind him.
The perp then whacked the officer, who crouched down while holding his head in pain.
He was charged with assault, criminal possession of a weapon, resisting arrest and disorderly conduct.
The detective suffered a gash to his head and a whip mark, according to his union.
No motive was immediately provided for the attack.
“Once again, New Yorkers witness just how emboldened violent criminals are,” DEA President Paul DiGiacomo said in a statement. “If there’s anyone wondering why this happened, they can ask their elected officials who have created a city of no consequence for criminality.”