> ## 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.

# Downloading a blob from Title Storage

> Flat C code sample for downloading a blob from XBOX services Title Storage using XblTitleStorageDownloadBlobAsync, with buffer sizing and block size guidance.

This topic demonstrates how to download a blob from XBOX services Title Storage by using the following flat C code example.

## Notes about XblTitleStorageDownloadBlobAsync parameters

* The buffer that you provide to store the downloaded blob data must be large enough to store the blob that's being downloaded. If you need to, you can retrieve the length that's required for the buffer by getting the blob metadata.

* This API returns E\_NOT\_SUFFICIENT\_BUFFER (0x8007007A) if `blobBuffer` doesn't have enough capacity to hold the blob data.

* To use the default size, pass 0 for `preferredDownloadBlockSize`.

#### 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();
}
```

## See also

[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 example code](/services/xbox-services/storage/title-storage/how-to/live-title-storage-howto-nav.md)
- [How to](/services/xbox-services/storage/title-storage/how-to/index.md)
- [Uploading a blob to Title Storage](/services/xbox-services/storage/title-storage/how-to/live-uploading-title-storage-blob.md)
- [Deleting a blob from Title Storage](/services/xbox-services/storage/title-storage/how-to/live-deleting-title-storage-blob.md)
- [Getting Title Storage blob metadata](/services/xbox-services/storage/title-storage/how-to/live-getting-title-storage-blob-metadata.md)
