

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

# 创建数据存储
<a name="create-data-store"></a>

使用`CreateDatastore`操作创建用于导入 DICOM P10 [文件的 AWS HealthImaging 数据存储](getting-started-concepts.md#concept-data-store)。以下菜单提供了操作步骤 AWS 管理控制台 和 AWS CLI 和的代码示例 AWS SDKs。有关更多信息，请参阅 *AWS HealthImaging API 参考[https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_CreateDatastore.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_CreateDatastore.html)*中的。创建数据存储时，您可以选择 AWS HealthImaging 用于转码和存储无损图像帧的默认传输语法。创建数据存储后，无法更改此配置。

**高吞吐量 JPEG 2000 (HTJ2K)**  
HTJ2K（高吞吐量 JPEG 2000）是 HealthImaging 数据存储的默认存储格式。它是 JPEG 2000 标准的扩展，可显著提高编码和解码性能。在未指定 a 的情况下创建数据存储时`—lossless-storage-format`， HealthImaging 会自动使用 HTJ2 K。有关使用 HTJ2 K 创建数据存储*的信息，请参阅 AWS CLI 和*以下 SDKs部分。

**JPEG 2000 Lossless**  
JPEG 2000 无损编码允许创建无需转码即可保留和检索 JPEG 2000 格式的无损图像帧的数据存储库，从而为需要 JPEG 2000 Lossless（DICOM 传输语法 UID 1.2.840.10008.1.2.4.90）的应用程序实现更低的检索延迟，详情请参阅。[支持的传输语法](supported-transfer-syntaxes.md)有关使用 JPEG 2000 无损格式创建数据存储的信息，请参阅 *AWS CLI 和*以下 SDKs部分。

**重要提示**  
请勿使用受保护的健康信息 (PHI)、个人身份信息 (PII) 或其他机密或敏感信息为数据存储命名。
AWS 控制台支持使用默认设置创建数据存储。使用 AWS CLI 或 AWS SDK 创建`—lossless-storage-format`指定了可选内容的数据存储。

**创建数据存储**  
根据您对 AWS 的访问偏好选择菜单 HealthImaging。

## AWS 控制台
<a name="code-example-console-data-store-create"></a>

1. 打开 HealthImaging 控制台 “[创建数据存储” 页面](https://console.aws.amazon.com/medical-imaging/home#/dataStores/create)。

1. 在**详细信息**下的**数据存储名称**中，输入数据存储的名称。

1. 在 “**数据加密**” 下，选择用于加密资源的 AWS KMS 密钥。有关更多信息，请参阅 [AWS 中的数据保护 HealthImaging](data-protection.md)。

1. 在**标签 - *可选***下，您可以在创建数据存储时向其添加标签。有关更多信息，请参阅 [标记资源](tag-resource.md)。

1. 选择**创建数据存储**。

## AWS CLI 和 SDKs
<a name="code-example-cli-sdk-data-store-create"></a>

------
#### [ Bash ]

**AWS CLI 使用 Bash 脚本**  

```
###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

###############################################################################
# function imaging_create_datastore
#
# This function creates an AWS HealthImaging data store for importing DICOM P10 files.
#
# Parameters:
#       -n data_store_name - The name of the data store.
#
# Returns:
#       The datastore ID.
#    And:
#       0 - If successful.
#       1 - If it fails.
###############################################################################
function imaging_create_datastore() {
  local datastore_name response
  local option OPTARG # Required to use getopts command in a function.

  # bashsupport disable=BP5008
  function usage() {
    echo "function imaging_create_datastore"
    echo "Creates an AWS HealthImaging data store for importing DICOM P10 files."
    echo "  -n data_store_name - The name of the data store."
    echo ""
  }

  # Retrieve the calling parameters.
  while getopts "n:h" option; do
    case "${option}" in
      n) datastore_name="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$datastore_name" ]]; then
    errecho "ERROR: You must provide a data store name with the -n parameter."
    usage
    return 1
  fi

  response=$(aws medical-imaging create-datastore \
    --datastore-name "$datastore_name" \
    --output text \
    --query 'datastoreId')

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports medical-imaging create-datastore operation failed.$response"
    return 1
  fi

  echo "$response"

  return 0
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateDatastore](https://docs.aws.amazon.com/goto/aws-cli/medical-imaging-2023-07-19/CreateDatastore)*中的。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/medical-imaging#code-examples)中查找完整示例，了解如何进行设置和运行。

------
#### [ CLI ]

**AWS CLI**  
**示例 1：创建数据存储**  
以下 `create-datastore` 代码示例创建名称为 `my-datastore` 的数据存储。在未指定 a 的情况下创建数据存储时`--lossless-storage-format`， AWS HealthImaging 默认为 HTJ2 K（高吞吐量 JPEG 2000）。  

```
aws medical-imaging create-datastore \
    --datastore-name "my-datastore"
```
输出：  

```
{
    "datastoreId": "12345678901234567890123456789012",
    "datastoreStatus": "CREATING"
}
```
**示例 2：采用 JPEG 2000 无损存储格式创建数据存储**  
使用 JPEG 2000 无损存储格式配置的数据存储将会转码并以 JPEG 2000 格式保存无损图像帧。然后，无需转码即可在 JPEG 2000 无损存储中检索图像帧。以下 `create-datastore` 代码示例创建配置为 JPEG 2000 无损存储格式的数据存储，其名称为 `my-datastore`。  

```
aws medical-imaging create-datastore \
    --datastore-name "my-datastore" \
    --lossless-storage-format JPEG_2000_LOSSLESS
```
输出：  

```
{
    "datastoreId": "12345678901234567890123456789012",
    "datastoreStatus": "CREATING"
}
```
有关更多信息，请参阅《*AWS HealthImaging 开发人员指南》*中的[创建数据存储](https://docs.aws.amazon.com/healthimaging/latest/devguide/create-data-store.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateDatastore](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/medical-imaging/create-datastore.html)*中的。

------
#### [ Java ]

**适用于 Java 的 SDK 2.x**  

```
    public static String createMedicalImageDatastore(MedicalImagingClient medicalImagingClient,
            String datastoreName) {
        try {
            CreateDatastoreRequest datastoreRequest = CreateDatastoreRequest.builder()
                    .datastoreName(datastoreName)
                    .build();
            CreateDatastoreResponse response = medicalImagingClient.createDatastore(datastoreRequest);
            return response.datastoreId();
        } catch (MedicalImagingException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }

        return "";
    }
```
+  有关 API 的详细信息，请参阅 *AWS SDK for Java 2.x API 参考[CreateDatastore](https://docs.aws.amazon.com/goto/SdkForJavaV2/medical-imaging-2023-07-19/CreateDatastore)*中的。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/medicalimaging#code-examples)中查找完整示例，了解如何进行设置和运行。

------
#### [ JavaScript ]

**适用于 JavaScript (v3) 的软件开发工具包**  

```
import { CreateDatastoreCommand } from "@aws-sdk/client-medical-imaging";
import { medicalImagingClient } from "../libs/medicalImagingClient.js";

/**
 * @param {string} datastoreName - The name of the data store to create.
 */
export const createDatastore = async (datastoreName = "DATASTORE_NAME") => {
  const response = await medicalImagingClient.send(
    new CreateDatastoreCommand({ datastoreName: datastoreName }),
  );
  console.log(response);
  // {
  //   '$metadata': {
  //       httpStatusCode: 200,
  //       requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b',
  //       extendedRequestId: undefined,
  //       cfId: undefined,
  //       attempts: 1,
  //       totalRetryDelay: 0
  //    },
  //    datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  //    datastoreStatus: 'CREATING'
  // }
  return response;
};
```
+  有关 API 的详细信息，请参阅 *适用于 JavaScript 的 AWS SDK API 参考[CreateDatastore](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/medical-imaging/command/CreateDatastoreCommand)*中的。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/medical-imaging#code-examples)中查找完整示例，了解如何进行设置和运行。

------
#### [ Python ]

**适用于 Python 的 SDK（Boto3）**  

```
class MedicalImagingWrapper:
    def __init__(self, health_imaging_client):
        self.health_imaging_client = health_imaging_client


    def create_datastore(self, name):
        """
        Create a data store.

        :param name: The name of the data store to create.
        :return: The data store ID.
        """
        try:
            data_store = self.health_imaging_client.create_datastore(datastoreName=name)
        except ClientError as err:
            logger.error(
                "Couldn't create data store %s. Here's why: %s: %s",
                name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return data_store["datastoreId"]
```
以下代码实例化对象。 MedicalImagingWrapper   

```
    client = boto3.client("medical-imaging")
    medical_imaging_wrapper = MedicalImagingWrapper(client)
```
+  有关 API 的详细信息，请参阅适用[CreateDatastore](https://docs.aws.amazon.com/goto/boto3/medical-imaging-2023-07-19/CreateDatastore)于 *Python 的AWS SDK (Boto3) API 参考*。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/medical-imaging#code-examples)中查找完整示例，了解如何进行设置和运行。

------
#### [ SAP ABAP ]

**适用于 SAP ABAP 的 SDK**  

```
    TRY.
        " iv_datastore_name = 'my-datastore-name'
        oo_result = lo_mig->createdatastore( iv_datastorename = iv_datastore_name ).
        DATA(lv_datastore_id) = oo_result->get_datastoreid( ).
        MESSAGE 'Data store created.' TYPE 'I'.
      CATCH /aws1/cx_migaccessdeniedex.
        MESSAGE 'Access denied.' TYPE 'I'.
      CATCH /aws1/cx_migconflictexception.
        MESSAGE 'Conflict. Data store may already exist.' TYPE 'I'.
      CATCH /aws1/cx_miginternalserverex.
        MESSAGE 'Internal server error.' TYPE 'I'.
      CATCH /aws1/cx_migservicequotaexcdex.
        MESSAGE 'Service quota exceeded.' TYPE 'I'.
      CATCH /aws1/cx_migthrottlingex.
        MESSAGE 'Request throttled.' TYPE 'I'.
      CATCH /aws1/cx_migvalidationex.
        MESSAGE 'Validation error.' TYPE 'I'.
    ENDTRY.
```
+  有关 API 的详细信息，请参阅适用[CreateDatastore](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)于 S *AP 的AWS SDK ABAP API 参考*。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/mig#code-examples)中查找完整示例，了解如何进行设置和运行。

------

**示例可用性**  
找不到所需的内容？ 使用本页右侧边栏上的 “**提供反馈**” 链接请求代码示例。