public BoxFile . Info commit ( String digest , List < BoxFileUploadSessionPart > parts , Map < String , String > attributes , String ifMatch , String ifNoneMatch ) { URL commitURL = this . sessionInfo . getSessionEndpoints ( ) . getCommitEndpoint ( ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , commitURL , HttpMethod . POST ) ; request . addHeader ( HttpHeaders . DIGEST , DIGEST_HEADER_PREFIX_SHA + digest ) ; request . addHeader ( HttpHeaders . CONTENT_TYPE , ContentType . APPLICATION_JSON ) ; if ( ifMatch != null ) { request . addHeader ( HttpHeaders . IF_MATCH , ifMatch ) ; } if ( ifNoneMatch != null ) { request . addHeader ( HttpHeaders . IF_NONE_MATCH , ifNoneMatch ) ; } //Creates the body of the request String body = this . getCommitBody ( parts , attributes ) ; request . setBody ( body ) ; BoxAPIResponse response = request . send ( ) ; //Retry the commit operation after the given number of seconds if the HTTP response code is 202. if ( response . getResponseCode ( ) == 202 ) { String retryInterval = response . getHeaderField ( "retry-after" ) ; if ( retryInterval != null ) { try { Thread . sleep ( new Integer ( retryInterval ) * 1000 ) ; } catch ( InterruptedException ie ) { throw new BoxAPIException ( "Commit retry failed. " , ie ) ; } return this . commit ( digest , parts , attributes , ifMatch , ifNoneMatch ) ; } } if ( response instanceof BoxJSONResponse ) { //Create the file instance from the response return this . getFile ( ( BoxJSONResponse ) response ) ; } else { throw new BoxAPIException ( "Commit response content type is not application/json. The response code : " + response . getResponseCode ( ) ) ; } }
Commit an upload session after all parts have been uploaded creating the new file or the version .