

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 STOW-RS 存储实例
<a name="dicomweb-storing"></a>

AWS HealthImaging 提供了[https://www.dicomstandard.org/using/dicomweb/store-stow-rs](https://www.dicomstandard.org/using/dicomweb/store-stow-rs) APIs 用于导入数据的表示形式。使用它们 APIs 将 DICOM 数据同步存储到您的 HealthImaging 数据存储中。

下表描述了 APIs 可用于导入 HealthImaging 数据的 DICOMweb STOW-RS 表示法。


**HealthImaging DICOMweb STOW-RS 的陈述 APIs**  

| Name | 说明 | 
| --- | --- | 
| StoreDICOM | 将一个或多个实例存储到 HealthImaging 数据存储中。 | 
| StoreDICOMStudy | 将与指定研究实例 UID 对应的一个或多个实例存储到 HealthImaging 数据存储中。 | 

使用`StoreDICOM`和`StoreDICOMStudy`操作导入的数据将组织为新的主影像集，或使用与异步[导入任务](https://docs.aws.amazon.com/healthimaging/latest/devguide/understanding-import-jobs.html)相同的逻辑添加到现有的主影像集中。[如果新导入的 DICOM P10 数据的元数据元素与现有的主[影像集](https://docs.aws.amazon.com/healthimaging/latest/devguide/getting-started-concepts.html#concept-image-set)冲突，则新数据将被添加到非主影像集。](https://docs.aws.amazon.com/healthimaging/latest/devguide/getting-started-concepts.html#concept-image-set)

**注意**  
这些操作支持每次请求上传最多 1GB 的 DICOM 数据。
API 响应将采用 JSON 格式，符合 STOW-RS 标准。 DICOMweb 

**发起 StorediCom 请求**  


1. 收集您的 AWS 区域和 DICOM P10 文件名。 HealthImaging `datastoreId`

1. 为表单的请求构造一个 URL：`https://dicom-medical-imaging.region.amazonaws.com/datastore/datastore-id/studies`

1. 例如，使用您的首选命令确定 DICOM P10 文件的内容长度。`$(stat -f %z $FILENAME)`

1. 准备并发送您的请求。 `StoreDICOM`使用带有 [AWS 签名版本 4 签名](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)协议的 HTTP POST 请求。

 

**Example 示例 1：使用操作存储 DICOM P10 文件 `StoreDICOM`**  

```
curl -X POST -v \
  'https://dicom-medical-imaging.us-east-1.amazonaws.com/datastore/d9a2a515ab294163a2d2f4069eed584c/studies' \
  --aws-sigv4 "aws:amz:$AWS_REGION:medical-imaging" \
  --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
  --header "x-amz-security-token:$AWS_SESSION_TOKEN" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: $CONTENT_LENGTH" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: application/dicom" \
  --upload-file $FILENAME
```

**Example 示例 2：使用操作存储 DICOM P10 文件 `StoreDICOMStudy`**  
StorediCom 和 Store 的唯一区别DICOMStudy 是，研究实例 UID 作为参数传递给 StoreDICOMStudy，并且上传的实例必须是指定研究的成员。  

```
curl -X POST -v \
  'https://dicom-medical-imaging.us-east-1.amazonaws.com/datastore/d9a2a515ab294163a2d2f4069eed584c/studies/1.3.6.1.4.1.5962.1.2.4.20040826285059.5457' \
  --aws-sigv4 "aws:amz:$AWS_REGION:medical-imaging" \
  --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
  --header "x-amz-security-token:$AWS_SESSION_TOKEN" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: $CONTENT_LENGTH" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: application/dicom" \
  --upload-file $FILENAME
```

**Example 示例 3：使用多部分 HTTP 有效负载存储 DICOM P10 文件**  
通过单个分段上传操作即可上传多个 P10 文件。以下 shell 命令演示了如何组装包含两个 P10 文件的多部分有效负载，并通过操作将其上`StoreDICOM`传。  

```
#!/bin/sh
FILENAME=multipart.payload
BOUNDARY=2a8a02b9-0ed3-c8a7-7ebd-232427531940
boundary_str="--$BOUNDARY\r\n"
mp_header="${boundary_str}Content-Type: application/dicom\r\n\r\n"

##Encapsulate the binary DICOM file 1.
printf '%b' "$mp_header" > $FILENAME
cat file1.dcm >> $FILENAME

##Encapsulate the binary DICOM file 2 (note the additional CRLF before the part header).
printf '%b' "\r\n$mp_header" >> $FILENAME
cat file2.dcm >> $FILENAME

## Add the closing boundary.
printf '%b' "\r\n--$BOUNDARY--" >> $FILENAME

## Obain the payload size in bytes.
multipart_payload_size=$(stat -f%z "$FILENAME")

# Execute CURL POST request with AWS SIGv4
curl -X POST -v \
  'https://iad-dicom.external-healthlake-imaging.ai.aws.dev/datastore/b5f34e91ca734b39a54ac11ea42416cf/studies' \
  --aws-sigv4 "aws:amz:us-east-1:medical-imaging" \
  --user "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: ${multipart_payload_size}" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: multipart/related; type=\"application/dicom\"; boundary=\"${BOUNDARY}\"" \
  --data-binary "@$FILENAME"

# Delete the payload file
rm $FILENAME
```