@PostMapping(consumes="!multipart/form-data") public ResponseEntity<FileInfo> uploadFile(HttpServletRequest request,@RequestParam(required=false) String name){
  try {
    String contentLength=request.getHeader("Content-Length");
    long size=0;
    try {
      size=Long.valueOf(contentLength);
    }
 catch (    NumberFormatException ignored) {
    }
    FileDescriptor fd=createFileDescriptor(name,size);
    ServletInputStream is=request.getInputStream();
    uploadToMiddleware(is,fd);
    saveFileDescriptor(fd);
    return createFileInfoResponseEntity(request,fd);
  }
 catch (  Exception e) {
    log.error("File upload failed",e);
    throw new RestAPIException("File upload failed","File upload failed",HttpStatus.INTERNAL_SERVER_ERROR);
  }
}

@ PostMapping ( consumes = "!multipart/form-data" ) public ResponseEntity < FileInfo > uploadFile ( HttpServletRequest request , @ RequestParam ( required = false ) String name ) { try { String contentLength = request . getHeader ( "Content-Length" ) ; long size = 0 ; try { size = Long . valueOf ( contentLength ) ; } catch ( NumberFormatException ignored ) { } FileDescriptor fd = createFileDescriptor ( name , size ) ; ServletInputStream is = request . getInputStream ( ) ; uploadToMiddleware ( is , fd ) ; saveFileDescriptor ( fd ) ; return createFileInfoResponseEntity ( request , fd ) ; } catch ( Exception e ) { log . error ( "File upload failed" , e ) ; throw new RestAPIException ( "File upload failed" , "File upload failed" , HttpStatus . INTERNAL_SERVER_ERROR ) ; } }
method for simple file upload . file contents are placed in the request body . optional file name parameter is passed as a query param .
