

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 二進位資料處理變更
<a name="migration-binary-data"></a>

在第 1 版中，二進位資料是直接使用 `ByteBuffer` 物件處理。在第 2 版中，軟體開發套件使用`SdkBytes`物件，提供更便利且類型安全的方式來使用二進位資料。

您可以使用[遷移工具](migration-tool.md)`ByteBuffer`自動`SdkBytes`轉換為 ，也可以在傳回的`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());
```