@@ -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 };
0 commit comments