Algorithm for Upload process