I am using RESTful endpoints for some file operations. I would want to post a jar file to my service via REST , I tried below approach but still it fails, I almost tried googling but could not find any solution.
@RestController
public class MyController {
...
@RequestMapping(value="/jobs/upload", method=RequestMethod.POST)
public @ResponseBody ResponseEntity<Void> handleFileUpload(HttpEntity<byte[]> requestEntity){
byte[] payload = requestEntity.getBody();
InputStream logo = new ByteArrayInputStream(payload);
HttpHeaders headers = requestEntity.getHeaders();
return ResponseEntity.ok().build();
}
...
}
Curl Command : curl -X POST --data-binary @/Users/path/to-jar/test-jar.jar localhost:8008/ctx/jobs/upload
[EDIT] : If I have to achive via --data-binary , how should my code look like?
I am not able to proceed further could anyone please help. I saw lot of solutions on MultiPart but I am not able to fit it in.