azure-storage-blobs
block_blob_client.hpp
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
4 #pragma once
5 
6 #include "azure/core/credentials/credentials.hpp"
7 #include "azure/storage/blobs/blob_client.hpp"
8 #include "azure/storage/blobs/blob_options.hpp"
9 #include "azure/storage/blobs/protocol/blob_rest_client.hpp"
10 #include "azure/storage/common/storage_credential.hpp"
11 
12 #include <map>
13 #include <string>
14 
15 namespace Azure { namespace Storage { namespace Files { namespace DataLake {
16  class FileClient;
17 }}}} // namespace Azure::Storage::Files::DataLake
18 
19 namespace Azure { namespace Storage { namespace Blobs {
20 
34  class BlockBlobClient : public BlobClient {
35  public:
48  const std::string& connectionString,
49  const std::string& containerName,
50  const std::string& blobName,
52 
64  explicit BlockBlobClient(
65  const std::string& blobUri,
66  std::shared_ptr<SharedKeyCredential> credential,
68 
79  explicit BlockBlobClient(
80  const std::string& blobUri,
81  std::shared_ptr<Core::Credentials::ClientSecretCredential> credential,
83 
94  explicit BlockBlobClient(
95  const std::string& blobUri,
97 
107  BlockBlobClient WithSnapshot(const std::string& snapshot) const;
108 
117  BlockBlobClient WithVersionId(const std::string& versionId) const;
118 
127  Azure::Core::Response<UploadBlockBlobResult> Upload(
128  Azure::Core::Http::BodyStream* content,
129  const UploadBlockBlobOptions& options = UploadBlockBlobOptions()) const;
130 
140  Azure::Core::Response<UploadBlockBlobFromResult> UploadFrom(
141  const uint8_t* buffer,
142  std::size_t bufferSize,
143  const UploadBlockBlobFromOptions& options = UploadBlockBlobFromOptions()) const;
144 
153  Azure::Core::Response<UploadBlockBlobFromResult> UploadFrom(
154  const std::string& file,
155  const UploadBlockBlobFromOptions& options = UploadBlockBlobFromOptions()) const;
156 
167  Azure::Core::Response<StageBlockResult> StageBlock(
168  const std::string& blockId,
169  Azure::Core::Http::BodyStream* content,
170  const StageBlockOptions& options = StageBlockOptions()) const;
171 
185  Azure::Core::Response<StageBlockFromUriResult> StageBlockFromUri(
186  const std::string& blockId,
187  const std::string& sourceUri,
188  const StageBlockFromUriOptions& options = StageBlockFromUriOptions()) const;
189 
203  Azure::Core::Response<CommitBlockListResult> CommitBlockList(
204  const std::vector<std::pair<BlockType, std::string>>& blockIds,
205  const CommitBlockListOptions& options = CommitBlockListOptions()) const;
206 
217  Azure::Core::Response<GetBlockListResult> GetBlockList(
218  const GetBlockListOptions& options = GetBlockListOptions()) const;
219 
220  private:
221  explicit BlockBlobClient(BlobClient blobClient);
222  friend class BlobClient;
223  friend class Files::DataLake::FileClient;
224  };
225 
226 }}} // namespace Azure::Storage::Blobs
Azure::Storage::Blobs::GetBlockListOptions
Optional parameters for BlockBlobClient::GetBlockList.
Definition: blob_options.hpp:1101
Azure::Storage::Blobs::BlockBlobClient::CreateFromConnectionString
static BlockBlobClient CreateFromConnectionString(const std::string &connectionString, const std::string &containerName, const std::string &blobName, const BlockBlobClientOptions &options=BlockBlobClientOptions())
Initialize a new instance of BlockBlobClient.
Definition: block_blob_client.cpp:14
Azure::Storage::Blobs::BlobClient
The BlobClient allows you to manipulate Azure Storage blobs.
Definition: blob_client.hpp:30
Azure::Storage::Blobs::UploadBlockBlobOptions
Optional parameters for BlockBlobClient::Upload.
Definition: blob_options.hpp:911
Azure::Storage::Blobs::UploadBlockBlobFromOptions
Optional parameters for BlockBlobClient::UploadFrom.
Definition: blob_options.hpp:956
Azure::Storage::Blobs::BlockBlobClientOptions
Block blob client options used to initalize BlockBlobClient.
Definition: blob_options.hpp:541
Azure::Storage::Blobs::BlockBlobClient::UploadFrom
Azure::Core::Response< UploadBlockBlobFromResult > UploadFrom(const uint8_t *buffer, std::size_t bufferSize, const UploadBlockBlobFromOptions &options=UploadBlockBlobFromOptions()) const
Creates a new block blob, or updates the content of an existing block blob. Updating an existing bloc...
Definition: block_blob_client.cpp:105
Azure::Storage::Blobs::CommitBlockListOptions
Optional parameters for BlockBlobClient::CommitBlockList.
Definition: blob_options.hpp:1070
Azure::Storage::Blobs::BlockBlobClient::StageBlockFromUri
Azure::Core::Response< StageBlockFromUriResult > StageBlockFromUri(const std::string &blockId, const std::string &sourceUri, const StageBlockFromUriOptions &options=StageBlockFromUriOptions()) const
Creates a new block to be committed as part of a blob where the contents are read from the sourceUri.
Definition: block_blob_client.cpp:286
Azure::Storage::Blobs::BlockBlobClient::GetBlockList
Azure::Core::Response< GetBlockListResult > GetBlockList(const GetBlockListOptions &options=GetBlockListOptions()) const
Retrieves the list of blocks that have been uploaded as part of a block blob. There are two block lis...
Definition: block_blob_client.cpp:351
Azure::Storage::Blobs::StageBlockOptions
Optional parameters for BlockBlobClient::StageBlock.
Definition: blob_options.hpp:992
Azure::Storage::Blobs::BlockBlobClient::WithVersionId
BlockBlobClient WithVersionId(const std::string &versionId) const
Creates a clone of this instance that references a version ID rather than the base blob.
Definition: block_blob_client.cpp:64
Azure::Storage::Blobs::BlockBlobClient
The BlockBlobClient allows you to manipulate Azure Storage block blobs.
Definition: block_blob_client.hpp:34
Azure::Storage::Blobs::BlockBlobClient::Upload
Azure::Core::Response< UploadBlockBlobResult > Upload(Azure::Core::Http::BodyStream *content, const UploadBlockBlobOptions &options=UploadBlockBlobOptions()) const
Creates a new block blob, or updates the content of an existing block blob. Updating an existing bloc...
Definition: block_blob_client.cpp:78
Azure::Storage::Blobs::BlockBlobClient::StageBlock
Azure::Core::Response< StageBlockResult > StageBlock(const std::string &blockId, Azure::Core::Http::BodyStream *content, const StageBlockOptions &options=StageBlockOptions()) const
Creates a new block as part of a block blob's staging area to be eventually committed via the CommitB...
Definition: block_blob_client.cpp:265
Azure::Storage::Blobs::BlockBlobClient::WithSnapshot
BlockBlobClient WithSnapshot(const std::string &snapshot) const
Initializes a new instance of the BlockBlobClient class with an identical uri source but the specifie...
Definition: block_blob_client.cpp:50
Azure::Storage::Blobs::StageBlockFromUriOptions
Optional parameters for BlockBlobClient::StageBlockFromUri.
Definition: blob_options.hpp:1022
Azure::Storage::Blobs::BlockBlobClient::BlockBlobClient
BlockBlobClient(const std::string &blobUri, std::shared_ptr< SharedKeyCredential > credential, const BlockBlobClientOptions &options=BlockBlobClientOptions())
Initialize a new instance of BlockBlobClient.
Definition: block_blob_client.cpp:25
Azure::Storage::Blobs::BlockBlobClient::CommitBlockList
Azure::Core::Response< CommitBlockListResult > CommitBlockList(const std::vector< std::pair< BlockType, std::string >> &blockIds, const CommitBlockListOptions &options=CommitBlockListOptions()) const
Writes a blob by specifying the list of block IDs that make up the blob. In order to be written as pa...
Definition: block_blob_client.cpp:325