

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

# 二进制数据处理更改
<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());
```