Initial code for R trigger

Clean up upload code