@Override public String append(String path,InputStream is) throws MalformedURLException, IOException, AuthenticationException {
  String resp=null;
  ensureValidToken();
  String spec=MessageFormat.format("/webhdfs/v1/{0}?op=APPEND&user.name={1}",URLUtil.encodePath(path),this.principal);
  String redirectUrl=null;
  HttpURLConnection conn=authenticatedURL.openConnection(new URL(new URL(httpfsUrl),spec),token);
  conn.setRequestMethod("POST");
  conn.setInstanceFollowRedirects(false);
  conn.connect();
  logger.info("Location:" + conn.getHeaderField("Location"));
  resp=result(conn,true);
  if (conn.getResponseCode() == 307)   redirectUrl=conn.getHeaderField("Location");
  conn.disconnect();
  if (redirectUrl != null) {
    conn=authenticatedURL.openConnection(new URL(redirectUrl),token);
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.setUseCaches(false);
    conn.setRequestProperty("Content-Type","application/octet-stream");
    final int _SIZE=is.available();
    conn.setRequestProperty("Content-Length","" + _SIZE);
    conn.setFixedLengthStreamingMode(_SIZE);
    conn.connect();
    OutputStream os=conn.getOutputStream();
    copy(is,os);
    is.close();
    os.close();
    resp=result(conn,true);
    conn.disconnect();
  }
  return resp;
}

@ Override public String append ( String path , InputStream is ) throws MalformedURLException , IOException , AuthenticationException { String resp = null ; ensureValidToken ( ) ; String spec = MessageFormat . format ( "/webhdfs/v1/{0}?op=APPEND&user.name={1}" , URLUtil . encodePath ( path ) , this . principal ) ; String redirectUrl = null ; HttpURLConnection conn = authenticatedURL . openConnection ( new URL ( new URL ( httpfsUrl ) , spec ) , token ) ; conn . setRequestMethod ( "POST" ) ; conn . setInstanceFollowRedirects ( false ) ; conn . connect ( ) ; logger . info ( "Location:" + conn . getHeaderField ( "Location" ) ) ; resp = result ( conn , true ) ; if ( conn . getResponseCode ( ) == 307 ) redirectUrl = conn . getHeaderField ( "Location" ) ; conn . disconnect ( ) ; if ( redirectUrl != null ) { conn = authenticatedURL . openConnection ( new URL ( redirectUrl ) , token ) ; conn . setRequestMethod ( "POST" ) ; conn . setDoOutput ( true ) ; conn . setDoInput ( true ) ; conn . setUseCaches ( false ) ; conn . setRequestProperty ( "Content-Type" , "application/octet-stream" ) ; final int _SIZE = is . available ( ) ; conn . setRequestProperty ( "Content-Length" , "" + _SIZE ) ; conn . setFixedLengthStreamingMode ( _SIZE ) ; conn . connect ( ) ; OutputStream os = conn . getOutputStream ( ) ; copy ( is , os ) ; is . close ( ) ; os . close ( ) ; resp = result ( conn , true ) ; conn . disconnect ( ) ; } return resp ; }
curl - i - x post " http : / / < host > : < port > / webhdfs / v1 / < path > ? op = append [ & buffersize = < int > ] "
