Rewrite upload with Java