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 <cstdint>
7 #include <string>
8 #include <vector>
9 
10 #include "azure/storage/blobs/blob_client.hpp"
11 
12 namespace Azure { namespace Storage { namespace Files { namespace DataLake {
13  class FileClient;
14 }}}} // namespace Azure::Storage::Files::DataLake
15 
16 namespace Azure { namespace Storage { namespace Blobs {
17 
31  class BlockBlobClient final : public BlobClient {
32  public:
45  const std::string& connectionString,
46  const std::string& blobContainerName,
47  const std::string& blobName,
48  const BlobClientOptions& options = BlobClientOptions());
49 
61  explicit BlockBlobClient(
62  const std::string& blobUrl,
63  std::shared_ptr<StorageSharedKeyCredential> credential,
64  const BlobClientOptions& options = BlobClientOptions());
65 
76  explicit BlockBlobClient(
77  const std::string& blobUrl,
78  std::shared_ptr<Core::Credentials::TokenCredential> credential,
79  const BlobClientOptions& options = BlobClientOptions());
80 
91  explicit BlockBlobClient(
92  const std::string& blobUrl,
93  const BlobClientOptions& options = BlobClientOptions());
94 
104  BlockBlobClient WithSnapshot(const std::string& snapshot) const;
105 
114  BlockBlobClient WithVersionId(const std::string& versionId) const;
115 
125  Azure::Response<Models::UploadBlockBlobResult> Upload(
126  Azure::Core::IO::BodyStream& content,
128  const Azure::Core::Context& context = Azure::Core::Context()) const;
129 
140  Azure::Response<Models::UploadBlockBlobFromResult> UploadFrom(
141  const uint8_t* buffer,
142  size_t bufferSize,
144  const Azure::Core::Context& context = Azure::Core::Context()) const;
145 
155  Azure::Response<Models::UploadBlockBlobFromResult> UploadFrom(
156  const std::string& fileName,
158  const Azure::Core::Context& context = Azure::Core::Context()) const;
159 
171  Azure::Response<Models::StageBlockResult> StageBlock(
172  const std::string& blockId,
173  Azure::Core::IO::BodyStream& content,
174  const StageBlockOptions& options = StageBlockOptions(),
175  const Azure::Core::Context& context = Azure::Core::Context()) const;
176 
191  Azure::Response<Models::StageBlockFromUriResult> StageBlockFromUri(
192  const std::string& blockId,
193  const std::string& sourceUri,
195  const Azure::Core::Context& context = Azure::Core::Context()) const;
196 
211  Azure::Response<Models::CommitBlockListResult> CommitBlockList(
212  const std::vector<std::string>& blockIds,
214  const Azure::Core::Context& context = Azure::Core::Context()) const;
215 
227  Azure::Response<Models::GetBlockListResult> GetBlockList(
228  const GetBlockListOptions& options = GetBlockListOptions(),
229  const Azure::Core::Context& context = Azure::Core::Context()) const;
230 
231  private:
232  explicit BlockBlobClient(BlobClient blobClient);
233  friend class BlobClient;
234  friend class Files::DataLake::DataLakeFileClient;
235  };
236 
237 }}} // namespace Azure::Storage::Blobs
Azure::Storage::Blobs::GetBlockListOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::GetBlockList.
Definition: blob_options.hpp:834
Azure::Storage::Blobs::BlockBlobClient::GetBlockList
Azure::Response< Models::GetBlockListResult > GetBlockList(const GetBlockListOptions &options=GetBlockListOptions(), const Azure::Core::Context &context=Azure::Core::Context()) 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:372
Azure::Storage::Blobs::BlockBlobClient::StageBlockFromUri
Azure::Response< Models::StageBlockFromUriResult > StageBlockFromUri(const std::string &blockId, const std::string &sourceUri, const StageBlockFromUriOptions &options=StageBlockFromUriOptions(), const Azure::Core::Context &context=Azure::Core::Context()) 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:314
Azure::Storage::Blobs::BlobClient
The BlobClient allows you to manipulate Azure Storage blobs.
Definition: blob_client.hpp:34
Azure::Storage::Blobs::UploadBlockBlobOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::Upload.
Definition: blob_options.hpp:683
Azure::Storage::Blobs::BlockBlobClient::Upload
Azure::Response< Models::UploadBlockBlobResult > Upload(Azure::Core::IO::BodyStream &content, const UploadBlockBlobOptions &options=UploadBlockBlobOptions(), const Azure::Core::Context &context=Azure::Core::Context()) const
Creates a new block blob, or updates the content of an existing block blob. Updating an existing bloc...
Definition: block_blob_client.cpp:92
Azure::Storage::Blobs::BlockBlobClient::CommitBlockList
Azure::Response< Models::CommitBlockListResult > CommitBlockList(const std::vector< std::string > &blockIds, const CommitBlockListOptions &options=CommitBlockListOptions(), const Azure::Core::Context &context=Azure::Core::Context()) 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:341
Azure::Storage::Blobs::UploadBlockBlobFromOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::UploadFrom.
Definition: blob_options.hpp:716
Azure::Storage::Blobs::BlobClientOptions
Client options used to initialize all kinds of blob clients.
Definition: blob_options.hpp:135
Azure::Storage::Blobs::CommitBlockListOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::CommitBlockList.
Definition: blob_options.hpp:808
Azure::Storage::Blobs::BlockBlobClient::StageBlock
Azure::Response< Models::StageBlockResult > StageBlock(const std::string &blockId, Azure::Core::IO::BodyStream &content, const StageBlockOptions &options=StageBlockOptions(), const Azure::Core::Context &context=Azure::Core::Context()) 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:293
Azure::Storage::Blobs::BlockBlobClient::BlockBlobClient
BlockBlobClient(const std::string &blobUrl, std::shared_ptr< StorageSharedKeyCredential > credential, const BlobClientOptions &options=BlobClientOptions())
Initialize a new instance of BlockBlobClient.
Definition: block_blob_client.cpp:39
Azure::Storage::Blobs::StageBlockOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::StageBlock.
Definition: blob_options.hpp:760
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:77
Azure::Storage::Blobs::BlockBlobClient
The BlockBlobClient allows you to manipulate Azure Storage block blobs.
Definition: block_blob_client.hpp:31
Azure::Storage::Blobs::BlockBlobClient::CreateFromConnectionString
static BlockBlobClient CreateFromConnectionString(const std::string &connectionString, const std::string &blobContainerName, const std::string &blobName, const BlobClientOptions &options=BlobClientOptions())
Initialize a new instance of BlockBlobClient.
Definition: block_blob_client.cpp:28
Azure::Storage::Blobs::BlockBlobClient::WithSnapshot
BlockBlobClient WithSnapshot(const std::string &snapshot) const
Initializes a new instance of the BlockBlobClient class with an identical URL source but the specifie...
Definition: block_blob_client.cpp:62
Azure::Storage::Blobs::StageBlockFromUriOptions
Optional parameters for Azure::Storage::Blobs::BlockBlobClient::StageBlockFromUri.
Definition: blob_options.hpp:778
Azure::Storage::Blobs::BlockBlobClient::UploadFrom
Azure::Response< Models::UploadBlockBlobFromResult > UploadFrom(const uint8_t *buffer, size_t bufferSize, const UploadBlockBlobFromOptions &options=UploadBlockBlobFromOptions(), const Azure::Core::Context &context=Azure::Core::Context()) const
Creates a new block blob, or updates the content of an existing block blob. Updating an existing bloc...
Definition: block_blob_client.cpp:119