Skip to content

Commit ad6550d

Browse files
noeroglesv
authored andcommitted
Change retrieved study output file to use .multipart extension and add Accept headers (GoogleCloudPlatform#1554)
* Change retrieved study output file to use .multipart extension * Address review comments * Add Accept headers to retrieve study request. * Address review comments/fix missing character * Fix style * Remove X-GFE-SSL yes header.
1 parent 1b75a32 commit ad6550d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

healthcare/v1beta1/src/main/java/snippets/healthcare/dicom/DicomWebRetrieveStudy.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public static void dicomWebRetrieveStudy(String dicomStoreName, String studyId)
6565
// Execute the request and process the results.
6666
HttpResponse response = request.executeUnparsed();
6767

68-
String outputPath = "study.dcm";
68+
// When specifying the output file, use an extension like ".multipart".
69+
// Then, parse the downloaded multipart file to get each individual
70+
// DICOM file.
71+
String outputPath = "study.multipart";
6972
OutputStream outputStream = new FileOutputStream(new File(outputPath));
7073
try {
7174
response.download(outputStream);
@@ -90,11 +93,20 @@ private static CloudHealthcare createClient() throws IOException {
9093
GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
9194
.createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));
9295

96+
HttpHeaders headers = new HttpHeaders();
97+
// The response's default transfer syntax is Little Endian Explicit.
98+
// As a result, if the file was uploaded using a compressed transfer syntax,
99+
// the returned object will be decompressed. This can negatively impact performance and lead
100+
// to errors for transfer syntaxes that the Cloud Healthcare API doesn't support.
101+
// To avoid these issues, and if the returned object's transfer syntax doesn't matter to
102+
// your application, use the
103+
// multipart/related; type="application/dicom"; transfer-syntax=* Accept Header.
104+
headers.setAccept("multipart/related; type=application/dicom; transfer-syntax=*");
93105
// Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
94106
HttpRequestInitializer requestInitializer =
95107
request -> {
96108
credential.initialize(request);
97-
request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
109+
request.setHeaders(headers);
98110
request.setConnectTimeout(60000); // 1 minute connect timeout
99111
request.setReadTimeout(60000); // 1 minute read timeout
100112
};

healthcare/v1beta1/src/test/java/snippets/healthcare/DicomWebTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class DicomWebTests {
6363

6464
private static String instanceOutput = "instance.dcm";
6565
private static String renderedOutput = "image.png";
66-
private static String studyOutput = "study.dcm";
66+
private static String studyOutput = "study.multipart";
6767

6868
private File outputFile;
6969

0 commit comments

Comments
 (0)