By Elizabeth Daley

PITTSBURGH (Reuters) - A Pennsylvania man who accidentally sold a tablet computer containing a video of himself raping an 8-year-old girl will spend at least 27 years in prison, authorities said on Friday.

Donald Miller, 43, of New Castle, pleaded guilty to a state count of rape of a child and a federal charge of producing child pornography, according to the U.S. Attorney's Office.

He was sentenced in the Lawrence County Court of Common Pleas on Thursday to between 15 and 30 years in prison to be served concurrently with a 27-year federal sentence imposed this month in Pittsburgh.

Miller will also have to register as a sex offender for the rest of his life and receive sex offender treatment when he is released, according to the Lawrence County District Attorney's office said.  

A New Castle woman who purchased the Samsung Galaxy tablet from Miller at a flea market across the border in Ohio on Christmas Eve of 2013 as a gift for her 5-year-old daughter discovered footage of Miller raping a child that had been stored on the device just days earlier.

New Castle is 18 miles east of Youngstown, Ohio.

"He thought he had deleted it and was trying to get rid of the evidence," said Lawrence County District Attorney Josh Lamancusa, "his own foolish actions ended up resulting in his incarceration."

Lamancusa said the woman went to the police and was able to identify Miller. 

Miller is currently in Lawrence County Prison but will soon be transferred to the State Correctional Institution in Pittsburgh, an Assistant District Attorney said.

Miller's attorneys could not be reached for comment. 

(Editing by Frank McGurty and Sandra Maler)