in ez_wsi_dicomweb/dicom_web_interface.py [0:0]
def get_bulkdata(self, uri: str, chunk_size=_STREAMING_CHUNKSIZE) -> bytes:
"""Returns binary data stored stored at bulkdata uri.
https://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.1.1.5
Args:
uri: DICOM store bulkdata uri to query.
chunk_size: Streaming chunk size.
Returns:
bytes from bulkdata uri.
Raises:
ez_wsi_errors.HTTPError if http error occurs.
"""
try:
headers = {'Accept': 'application/octet-stream; transfer-syntax=*'}
self.credentials().apply(headers)
with requests.Session() as session:
response = session.get(uri, headers=headers, stream=True)
with io.BytesIO() as output_stream:
response.raise_for_status()
for chunk in response.iter_content(chunk_size=max(1, chunk_size)):
output_stream.write(chunk)
return output_stream.getvalue()
except requests.exceptions.HTTPError as exp:
ez_wsi_errors.raise_ez_wsi_http_exception(exp.response.reason, exp)