public void postMultipart ( String url , Map < String , String > map ) throws Exception { String boundaryStr = "-----boundary0" ; StringBuilder sb = new StringBuilder ( ) ; map . forEach ( ( k , v ) -> { sb . append ( boundaryStr + "\r" ) ; sb . append ( "Content-Disposition: form-data; name=\"" + k + "\"\r" ) ; sb . append ( "\r" ) ; sb . append ( v ) ; sb . append ( "\r" ) ; } ) ; String request = "POST " + url + " HTTP/1.0\r" + "Content-Type: multipart/form-data; boundary=" + boundaryStr + "\r" + "Content-Length: " + sb . length ( ) + "\r" + "\r" + sb ; request ( request , null ) ; }
Performs multipart post