Downloading blob content

I missed this in the previous blog entry. The SDK makes it really trivial to extract blob data. For text content you can directly get the text, and for non-text content you can either download to a file or to a stream. The code snippet below shows how it’s done.

void DownloadBlobData()
  auto storage_account = cloud_storage_account::parse(
  auto blob_client = storage_account.create_cloud_blob_client();
  auto container = blob_client.get_container_reference(
  bool created = container.create_if_not_exists();

  // Read the text content directly
  auto text_blob1 = container.get_block_blob_reference(
  auto text = text_blob1.download_text();
  ucout << text << endl;

  // Download the blob data to a file
  auto text_blob2 = container.get_block_blob_reference(

  // Download the blob data to an ostream
  stringstreambuf buffer;
  concurrency::streams::ostream output(buffer);
  cout << buffer.collection() << endl;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s