> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Title Storage から blob をダウンロードする

> XblTitleStorageDownloadBlobAsync を使用して XBOX サービス Title Storage から blob をダウンロードするためのフラット C コード サンプル。バッファーのサイズ設定とブロック サイズのガイダンスを含みます。

このトピックでは、次のフラット C コード例を使用して XBOX サービス Title Storage から blob をダウンロードする方法を示します。

## XblTitleStorageDownloadBlobAsync のパラメーターに関する注意事項

* ダウンロードした blob データを格納するために提供するバッファーは、ダウンロード中の blob を格納するのに十分な大きさである必要があります。必要に応じて、blob のメタデータを取得することで、バッファーに必要な長さを取得できます。

* この API は、`blobBuffer` に blob データを保持するのに十分な容量がない場合、E\_NOT\_SUFFICIENT\_BUFFER (0x8007007A) を返します。

* 既定のサイズを使用するには、`preferredDownloadBlockSize` に 0 を渡します。

#### Flat C

```cpp theme={null}
std::unique_ptr<std::vector<uint8_t>> downloadBlobBuffer = std::make_unique<std::vector<uint8_t>>(blobMetadata.length);

auto asyncBlock = std::make_unique<XAsyncBlock>();
asyncBlock->queue = queue;
asyncBlock->context = downloadBlobBuffer.get();
asyncBlock->callback = [](XAsyncBlock* asyncBlock)
{
    std::unique_ptr<XAsyncBlock> asyncBlockPtr{ asyncBlock };   // Take over ownership of XAsyncBlock*.
    std::unique_ptr<std::vector<uint8_t>> downloadBlobBuffer{ static_cast<std::vector<uint8_t>*>(asyncBlock->context) };
    HRESULT hr = XblTitleStorageDownloadBlobResult(asyncBlock, &blobMetadata);
};

HRESULT hr = XblTitleStorageDownloadBlobAsync(
    xboxLiveContext,
    blobMetadata,
    downloadBlobBuffer->data(),
    blobMetadata.length,
    XblTitleStorageETagMatchCondition::NotUsed,
    selectQuery.c_str(),   // Optional  .
    preferredDownloadBlockSize,   // Optional.
    asyncBlock.get()
);

if (SUCCEEDED(hr))
{
    // The call succeeded, so release std::unique_ptr ownership of XAsyncBlock* because
    // the callback takes over ownership. If the call fails, however, std::unique_ptr keeps
    // ownership and deletes XAsyncBlock*.
    asyncBlock.release();
    downloadBlobBuffer.release();
}
```

## 関連項目

[XAsyncBlock](/reference/system/xasync/structs/xasyncblock)

[XblTitleStorageDownloadBlobAsync](/reference/live/xsapi-c/title_storage_c/functions/xbltitlestoragedownloadblobasync)

[XblTitleStorageDownloadBlobResult](/reference/live/xsapi-c/title_storage_c/functions/xbltitlestoragedownloadblobresult)

[XblTitleStorageETagMatchCondition](/reference/live/xsapi-c/title_storage_c/enums/xbltitlestorageetagmatchcondition)


## Related topics

- [Title Storage のサンプル コード](/ja-jp/services/xbox-services/storage/title-storage/how-to/live-title-storage-howto-nav.md)
- [ハウツー](/ja-jp/services/xbox-services/storage/title-storage/how-to/index.md)
- [Partner Center から Events Manifest ファイルをダウンロードする](/ja-jp/publishing/game-publishing/how-to/data-platform-2013/how-to-download-events-manifest.md)
- [Partner Center で XBOX イベントを構成する](/ja-jp/publishing/game-publishing/how-to/data-platform-2013/how-to-configure-events-2013.md)
- [Partner Center でサステナビリティ データを表示する](/ja-jp/build/game-principles/sustainability/partner-center-sustainability-data.md)
