in dicom_util/src/main/java/com/google/cloud/healthcare/DicomWebClient.java [132:164]
public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException {
GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath));
// DICOM "Type" parameter:
// http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_6.6.1.1.1
MultipartContent content = new MultipartContent();
content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\""));
content.setBoundary(UUID.randomUUID().toString());
InputStreamContent dicomStream = new InputStreamContent("application/dicom", in);
content.addPart(new MultipartContent.Part(dicomStream));
HttpResponse resp = null;
try {
HttpRequest httpRequest = requestFactory.buildPostRequest(url, content);
resp = httpRequest.execute();
} catch (HttpResponseException e) {
throw new DicomWebException(
String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()),
e,
e.getStatusCode(),
Status.ProcessingFailure);
} catch (IOException e) {
throw new IDicomWebClient.DicomWebException(e);
} finally {
try {
if ((resp) != null) {
resp.disconnect();
}
} catch (IOException e) {
throw new IDicomWebClient.DicomWebException(e);
}
}
}