public BoxFile . Info uploadFile ( FileUploadParams uploadParams ) { URL uploadURL = UPLOAD_FILE_URL . build ( this . getAPI ( ) . getBaseUploadURL ( ) ) ; BoxMultipartRequest request = new BoxMultipartRequest ( getAPI ( ) , uploadURL ) ; JsonObject fieldJSON = new JsonObject ( ) ; JsonObject parentIdJSON = new JsonObject ( ) ; parentIdJSON . add ( "id" , getID ( ) ) ; fieldJSON . add ( "name" , uploadParams . getName ( ) ) ; fieldJSON . add ( "parent" , parentIdJSON ) ; if ( uploadParams . getCreated ( ) != null ) { fieldJSON . add ( "content_created_at" , BoxDateFormat . format ( uploadParams . getCreated ( ) ) ) ; } if ( uploadParams . getModified ( ) != null ) { fieldJSON . add ( "content_modified_at" , BoxDateFormat . format ( uploadParams . getModified ( ) ) ) ; } if ( uploadParams . getSHA1 ( ) != null && ! uploadParams . getSHA1 ( ) . isEmpty ( ) ) { request . setContentSHA1 ( uploadParams . getSHA1 ( ) ) ; } if ( uploadParams . getDescription ( ) != null ) { fieldJSON . add ( "description" , uploadParams . getDescription ( ) ) ; } request . putField ( "attributes" , fieldJSON . toString ( ) ) ; if ( uploadParams . getSize ( ) > 0 ) { request . setFile ( uploadParams . getContent ( ) , uploadParams . getName ( ) , uploadParams . getSize ( ) ) ; } else if ( uploadParams . getContent ( ) != null ) { request . setFile ( uploadParams . getContent ( ) , uploadParams . getName ( ) ) ; } else { request . setUploadFileCallback ( uploadParams . getUploadFileCallback ( ) , uploadParams . getName ( ) ) ; } BoxJSONResponse response ; if ( uploadParams . getProgressListener ( ) == null ) { response = ( BoxJSONResponse ) request . send ( ) ; } else { response = ( BoxJSONResponse ) request . send ( uploadParams . getProgressListener ( ) ) ; } JsonObject collection = JsonObject . readFrom ( response . getJSON ( ) ) ; JsonArray entries = collection . get ( "entries" ) . asArray ( ) ; JsonObject fileInfoJSON = entries . get ( 0 ) . asObject ( ) ; String uploadedFileID = fileInfoJSON . get ( "id" ) . asString ( ) ; BoxFile uploadedFile = new BoxFile ( getAPI ( ) , uploadedFileID ) ; return uploadedFile . new Info ( fileInfoJSON ) ; }
Uploads a new file to this folder with custom upload parameters .