Ten years ago, they might have gotten away with it. Ten years ago, truth and justice might have been abused the way Nate Buckley was.

Our freedom to say what we want – a right bought in blood on countless battlefields – might have been trampled by abusive cops. We all would have been the worse for it.

Thanks largely to a digital recorder, justice was ultimately done and freedom of speech preserved.

First Amendment, meet technology. It looks to me like a beautiful friendship.

City Judge Joseph Fiorella last month gave the Niagara Frontier Transportation Authority the legal equivalent of the beating that its cops laid on Buckley two years ago. The judge dismissed charges against the 26-year-old activist of resisting arrest, trespassing and obstruction.

Buckley was part of an anti-war protest April 8, 2011, in front of Fountain Plaza, home of M&T Bank, in downtown Buffalo. Call it Dreadlocks Meets Brooks Brothers. NFTA cops came to keep the peace. Instead of preventing a confrontation, the cops created one.

Officers claimed that a kicking, spitting Buckley had to be subdued with pepper spray. Buckley said he was complying when NFTA cops Richard Russo and Adam Brodsky, with no provocation, flexed their muscles.

After getting whacked with a nightstick and pulled onto the plaza, Buckley said, he was needlessly pepper-sprayed by Brodsky. Hmm.

The case typically would have hinged on dueling testimony in court, with police getting the benefit of the doubt. Except for one thing: A demonstrator digitally recorded the confrontation. Quicker than you could say Flying Nightstick, the evidence was up on YouTube. It clearly showed Buckley, as he described, trying to leave the scene, getting chased down the sidewalk by Russo and dragged onto the plaza.

Moments later – while Buckley stood compliant – Brodsky, without cause, pepper-sprayed him in the face. It was a classic unprofessional cop’s payback to a protester. Bad.

Worse, Brodsky the previous year had roughed up a senior citizen at the downtown bus station. NFTA, you have a problem.

Years ago, the judge would have had only conflicting testimony to work with. This time, Fiorella had YouTube. The recording, backed by the bank’s security video, contradicted the police report and the transit cops’ testimony.

Score one for freedom of speech.

Fiorella, in an 11-page decision, hammered the abusive cops.

“The Court is troubled by the actions of the NFTA [police],” Fiorella wrote, saying they “engaged in improper conduct which is repugnant to this Court’s sense of justice.”

The NFTA subsequently set up an internal affairs unit, although neither officer – astoundingly – was disciplined.

To my mind, this case underlines how technology enhances our safety and preserves our rights.

Whether it is a witness reporting a crime-in-progress on a cellphone, or a demonstrator recording police brutality, technology is a 21st century backstop for our freedoms. Call it the upside of Big Brother.

“The two key pieces in the case,” Mike Kuzma, Buckley’s lawyer, told me, “were that video, and social media getting the word out.”

Ten years ago, it might have been a different story – without the happy ending.