Guest User

Untitled

a guest
Jun 23rd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. @RestController
  2. @RequestMapping("node-info")
  3. class NodeInfoController(val nodeInfoService: NodeInfoService) {
  4.  
  5. @PostMapping
  6. @ResponseStatus(HttpStatus.CREATED)
  7. fun saveNodeInfo(@RequestParam("file") file: MultipartFile) = nodeInfoService.saveNodeInfo(file)
  8. ....
  9.  
  10. }
  11.  
  12. override fun saveNodeInfo(file: MultipartFile) {
  13. val configWrapper = file.bytes.deserialize<SignedNodeInfo>()
  14. val name = configWrapper.raw.deserialize().legalIdentities.first().name
  15. ...
  16. }
  17.  
  18. override fun registerNodeInfo(nodeInfoFile: File): Mono<NodeInfoContainer> {
  19. val multipartBodyBuilder = MultipartBodyBuilder().apply {
  20. part("file", object : ByteArrayResource(nodeInfoFile.readBytes()){
  21. override fun getFilename(): String {
  22. return nodeInfoFile.name
  23. }
  24. })
  25. }
  26. return webClient.post()
  27. .uri("/node-info")
  28. .syncBody(multipartBodyBuilder.build())
  29. .retrieve()
  30. .bodyToMono()
  31. }
  32.  
  33. override fun saveNodeInfo(file: MultipartFile, token : String ){
  34. ...
  35. }
Add Comment
Please, Sign In to add comment