move out upload_paste function