move upload code to action