use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project OpenClinica by OpenClinica.
the class XformMetaDataService method saveAttachedFiles.
public void saveAttachedFiles(String uri, String dir, String fileName) throws IOException {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
HttpEntity<String> entity = new HttpEntity<String>(headers);
ResponseEntity<byte[]> response = restTemplate.exchange(uri, HttpMethod.GET, entity, byte[].class, "1");
if (response.getStatusCode().equals(HttpStatus.OK)) {
FileOutputStream output = new FileOutputStream(new File(dir + File.separator + fileName));
IOUtils.write(response.getBody(), output);
}
}
Aggregations