public BoxFileUploadSession . Info createUploadSession ( long fileSize ) { URL url = UPLOAD_SESSION_URL_TEMPLATE . build ( this . getAPI ( ) . getBaseUploadURL ( ) , this . getID ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , url , "POST" ) ; request . addHeader ( "Content-Type" , "application/json" ) ; JsonObject body = new JsonObject ( ) ; body . add ( "file_size" , fileSize ) ; request . setBody ( body . toString ( ) ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject jsonObject = JsonObject . readFrom ( response . getJSON ( ) ) ; String sessionId = jsonObject . get ( "id" ) . asString ( ) ; BoxFileUploadSession session = new BoxFileUploadSession ( this . getAPI ( ) , sessionId ) ; return session . new Info ( jsonObject ) ; }
Creates an upload session to create a new version of a file in chunks . This will first verify that the version can be created and then open a session for uploading pieces of the file .