

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# バイナリデータ処理の変更
<a name="migration-binary-data"></a>

バージョン 1 では、バイナリデータは `ByteBuffer` オブジェクトを使用して直接処理されていました。バージョン 2 では、SDK はバイナリデータを使用するためのより便利で型の安全性が高い方法を提供する `SdkBytes` オブジェクトを使用します。

[移行ツール](migration-tool.md)を使用して自動的に `SdkBytes` を `ByteBuffer` に変換することも、返された `SdkBytes` オブジェクトで `asByteBuffer()` を呼び出すことで手動で変換することもできます。

**Example - バージョン 1 でメッセージ属性からバイナリデータを取得する**  

```
// Get binary data from a message attribute
MessageAttributeValue messageAttributeValue = new MessageAttributeValue();
ByteBuffer binaryValue = messageAttributeValue.getBinaryValue();
String binaryString = new String(messageAttributeValue.getBinaryValue().array());
```

**Example - バージョン 2 でメッセージ属性からバイナリデータを取得する**  

```
// Get binary data from a message attribute
MessageAttributeValue messageAttributeValue = MessageAttributeValue.builder().build();
ByteBuffer binaryValue = messageAttributeValue.binaryValue().asByteBuffer();
String binaryString = new String(messageAttributeValue.binaryValue().asByteBuffer().array());
```