azure-storage-blobs
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Azure::Storage::Blobs::BlobClient Class Reference

The BlobClient allows you to manipulate Azure Storage blobs. More...

#include <blob_client.hpp>

Inheritance diagram for Azure::Storage::Blobs::BlobClient:
Azure::Storage::Blobs::AppendBlobClient Azure::Storage::Blobs::BlockBlobClient Azure::Storage::Blobs::PageBlobClient

Public Member Functions

 BlobClient (const std::string &blobUri, std::shared_ptr< SharedKeyCredential > credential, const BlobClientOptions &options=BlobClientOptions())
 Initialize a new instance of BlobClient. More...
 
 BlobClient (const std::string &blobUri, std::shared_ptr< Core::Credentials::ClientSecretCredential > credential, const BlobClientOptions &options=BlobClientOptions())
 Initialize a new instance of BlobClient. More...
 
 BlobClient (const std::string &blobUri, const BlobClientOptions &options=BlobClientOptions())
 Initialize a new instance of BlobClient. More...
 
BlockBlobClient GetBlockBlobClient () const
 Creates a new BlockBlobClient object with the same uri as this BlobClient. The new BlockBlobClient uses the same request policy pipeline as this BlobClient. More...
 
AppendBlobClient GetAppendBlobClient () const
 Creates a new AppendBlobClient object with the same uri as this BlobClient. The new AppendBlobClient uses the same request policy pipeline as this BlobClient. More...
 
PageBlobClient GetPageBlobClient () const
 Creates a new PageBlobClient object with the same uri as this BlobClient. The new PageBlobClient uses the same request policy pipeline as this BlobClient. More...
 
std::string GetUri () const
 Gets the blob's primary uri endpoint. More...
 
BlobClient WithSnapshot (const std::string &snapshot) const
 Initializes a new instance of the BlobClient class with an identical uri source but the specified snapshot timestamp. More...
 
BlobClient WithVersionId (const std::string &versionId) const
 Creates a clone of this instance that references a version ID rather than the base blob. More...
 
Azure::Core::Response< GetBlobPropertiesResultGetProperties (const GetBlobPropertiesOptions &options=GetBlobPropertiesOptions()) const
 Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob. More...
 
Azure::Core::Response< SetBlobHttpHeadersResultSetHttpHeaders (BlobHttpHeaders httpHeaders, const SetBlobHttpHeadersOptions &options=SetBlobHttpHeadersOptions()) const
 Sets system properties on the blob. More...
 
Azure::Core::Response< SetBlobMetadataResultSetMetadata (std::map< std::string, std::string > metadata, const SetBlobMetadataOptions &options=SetBlobMetadataOptions()) const
 Sets user-defined metadata for the specified blob as one or more name-value pairs. More...
 
Azure::Core::Response< SetBlobAccessTierResultSetAccessTier (AccessTier Tier, const SetBlobAccessTierOptions &options=SetBlobAccessTierOptions()) const
 Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage or general purpose v2 account. More...
 
Azure::Core::Response< StartCopyBlobFromUriResultStartCopyFromUri (const std::string &sourceUri, const StartCopyBlobFromUriOptions &options=StartCopyBlobFromUriOptions()) const
 Copies data at from the source to this blob. More...
 
Azure::Core::Response< AbortCopyBlobFromUriResultAbortCopyFromUri (const std::string &copyId, const AbortCopyBlobFromUriOptions &options=AbortCopyBlobFromUriOptions()) const
 Aborts a pending StartCopyFromUri operation, and leaves this blob with zero length and full metadata. More...
 
Azure::Core::Response< DownloadBlobResultDownload (const DownloadBlobOptions &options=DownloadBlobOptions()) const
 Downloads a blob or a blob range from the service, including its metadata and properties. More...
 
Azure::Core::Response< DownloadBlobToResultDownloadTo (uint8_t *buffer, std::size_t bufferSize, const DownloadBlobToOptions &options=DownloadBlobToOptions()) const
 Downloads a blob or a blob range from the service to a memory buffer using parallel requests. More...
 
Azure::Core::Response< DownloadBlobToResultDownloadTo (const std::string &file, const DownloadBlobToOptions &options=DownloadBlobToOptions()) const
 Downloads a blob or a blob range from the service to a file using parallel requests. More...
 
Azure::Core::Response< CreateBlobSnapshotResultCreateSnapshot (const CreateBlobSnapshotOptions &options=CreateBlobSnapshotOptions()) const
 Creates a read-only snapshot of a blob. More...
 
Azure::Core::Response< DeleteBlobResultDelete (const DeleteBlobOptions &options=DeleteBlobOptions()) const
 Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using DeleteBlobOptions.DeleteSnapshots. More...
 
Azure::Core::Response< UndeleteBlobResultUndelete (const UndeleteBlobOptions &options=UndeleteBlobOptions()) const
 Restores the contents and metadata of a soft deleted blob and any associated soft deleted snapshots. More...
 
Azure::Core::Response< AcquireBlobLeaseResultAcquireLease (const std::string &proposedLeaseId, int32_t duration, const AcquireBlobLeaseOptions &options=AcquireBlobLeaseOptions()) const
 Acquires a lease on the blob. More...
 
Azure::Core::Response< RenewBlobLeaseResultRenewLease (const std::string &leaseId, const RenewBlobLeaseOptions &options=RenewBlobLeaseOptions()) const
 Renews the blob's previously-acquired lease. More...
 
Azure::Core::Response< ReleaseBlobLeaseResultReleaseLease (const std::string &leaseId, const ReleaseBlobLeaseOptions &options=ReleaseBlobLeaseOptions()) const
 Releases the blob's previously-acquired lease. More...
 
Azure::Core::Response< ChangeBlobLeaseResultChangeLease (const std::string &leaseId, const std::string &proposedLeaseId, const ChangeBlobLeaseOptions &options=ChangeBlobLeaseOptions()) const
 Changes the lease of an active lease. More...
 
Azure::Core::Response< BreakBlobLeaseResultBreakLease (const BreakBlobLeaseOptions &options=BreakBlobLeaseOptions()) const
 Breaks the previously-acquired lease. More...
 
Azure::Core::Response< SetBlobTagsResultSetTags (std::map< std::string, std::string > tags, const SetBlobTagsOptions &options=SetBlobTagsOptions()) const
 Sets tags on the underlying blob. More...
 
Azure::Core::Response< GetBlobTagsResultGetTags (const GetBlobTagsOptions &options=GetBlobTagsOptions()) const
 Gets the tags associated with the underlying blob. More...
 

Static Public Member Functions

static BlobClient CreateFromConnectionString (const std::string &connectionString, const std::string &containerName, const std::string &blobName, const BlobClientOptions &options=BlobClientOptions())
 Initialize a new instance of BlobClient. More...
 

Protected Attributes

Azure::Core::Http::Url m_blobUrl
 
std::shared_ptr< Azure::Core::Http::HttpPipeline > m_pipeline
 
Azure::Core::Nullable< EncryptionKeym_customerProvidedKey
 
Azure::Core::Nullable< std::string > m_encryptionScope
 

Friends

class BlobContainerClient
 
class Files::DataLake::DirectoryClient
 
class Files::DataLake::FileClient
 

Detailed Description

The BlobClient allows you to manipulate Azure Storage blobs.

Constructor & Destructor Documentation

◆ BlobClient() [1/3]

Azure::Storage::Blobs::BlobClient::BlobClient ( const std::string &  blobUri,
std::shared_ptr< SharedKeyCredential >  credential,
const BlobClientOptions options = BlobClientOptions() 
)
explicit

Initialize a new instance of BlobClient.

Parameters
blobUriA uri referencing the blob that includes the name of the account, the name of the container, and the name of the blob.
credentialThe shared key credential used to sign requests.
optionsOptional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
47  : BlobClient(blobUri, options)
48  {
49  std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
50  policies.emplace_back(std::make_unique<Azure::Core::Http::TelemetryPolicy>(
51  Details::c_BlobServicePackageName, BlobServiceVersion));
52  policies.emplace_back(std::make_unique<Azure::Core::Http::RequestIdPolicy>());
53  for (const auto& p : options.PerOperationPolicies)
54  {
55  policies.emplace_back(p->Clone());
56  }
57  policies.emplace_back(
58  std::make_unique<Azure::Core::Http::RetryPolicy>(Azure::Core::Http::RetryOptions()));
59  for (const auto& p : options.PerRetryPolicies)
60  {
61  policies.emplace_back(p->Clone());
62  }
63  policies.emplace_back(std::make_unique<StoragePerRetryPolicy>());
64  policies.emplace_back(std::make_unique<SharedKeyPolicy>(credential));
65  policies.emplace_back(std::make_unique<Azure::Core::Http::TransportPolicy>(
66  std::make_shared<Azure::Core::Http::CurlTransport>()));
67  m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
68  }

◆ BlobClient() [2/3]

Azure::Storage::Blobs::BlobClient::BlobClient ( const std::string &  blobUri,
std::shared_ptr< Core::Credentials::ClientSecretCredential >  credential,
const BlobClientOptions options = BlobClientOptions() 
)
explicit

Initialize a new instance of BlobClient.

Parameters
blobUriA uri referencing the blob that includes the name of the account, the name of the container, and the name of the blob.
credentialThe client secret credential used to sign requests.
optionsOptional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
74  : BlobClient(blobUri, options)
75  {
76  std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
77  policies.emplace_back(std::make_unique<Azure::Core::Http::TelemetryPolicy>(
78  Details::c_BlobServicePackageName, BlobServiceVersion));
79  policies.emplace_back(std::make_unique<Azure::Core::Http::RequestIdPolicy>());
80  for (const auto& p : options.PerOperationPolicies)
81  {
82  policies.emplace_back(p->Clone());
83  }
84  policies.emplace_back(
85  std::make_unique<Azure::Core::Http::RetryPolicy>(Azure::Core::Http::RetryOptions()));
86  for (const auto& p : options.PerRetryPolicies)
87  {
88  policies.emplace_back(p->Clone());
89  }
90  policies.emplace_back(std::make_unique<StoragePerRetryPolicy>());
91  policies.emplace_back(
92  std::make_unique<Core::Credentials::Policy::BearerTokenAuthenticationPolicy>(
93  credential, Details::c_StorageScope));
94  policies.emplace_back(std::make_unique<Azure::Core::Http::TransportPolicy>(
95  std::make_shared<Azure::Core::Http::CurlTransport>()));
96  m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
97  }

◆ BlobClient() [3/3]

Azure::Storage::Blobs::BlobClient::BlobClient ( const std::string &  blobUri,
const BlobClientOptions options = BlobClientOptions() 
)
explicit

Initialize a new instance of BlobClient.

Parameters
blobUriA uri referencing the blob that includes the name of the account, the name of the container, and the name of the blob, and possibly also a SAS token.
optionsOptional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
100  : m_blobUrl(blobUri), m_customerProvidedKey(options.CustomerProvidedKey),
101  m_encryptionScope(options.EncryptionScope)
102  {
103  std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
104  policies.emplace_back(std::make_unique<Azure::Core::Http::TelemetryPolicy>(
105  Details::c_BlobServicePackageName, BlobServiceVersion));
106  policies.emplace_back(std::make_unique<Azure::Core::Http::RequestIdPolicy>());
107  for (const auto& p : options.PerOperationPolicies)
108  {
109  policies.emplace_back(p->Clone());
110  }
111  policies.emplace_back(
112  std::make_unique<Azure::Core::Http::RetryPolicy>(Azure::Core::Http::RetryOptions()));
113  for (const auto& p : options.PerRetryPolicies)
114  {
115  policies.emplace_back(p->Clone());
116  }
117  policies.emplace_back(std::make_unique<StoragePerRetryPolicy>());
118  policies.emplace_back(std::make_unique<Azure::Core::Http::TransportPolicy>(
119  std::make_shared<Azure::Core::Http::CurlTransport>()));
120  m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
121  }

Member Function Documentation

◆ AbortCopyFromUri()

Azure::Core::Response< AbortCopyBlobFromUriResult > Azure::Storage::Blobs::BlobClient::AbortCopyFromUri ( const std::string &  copyId,
const AbortCopyBlobFromUriOptions options = AbortCopyBlobFromUriOptions() 
) const

Aborts a pending StartCopyFromUri operation, and leaves this blob with zero length and full metadata.

Parameters
copyIdID of the copy operation to abort.
optionsOptional parameters to execute this function.
Returns
A AbortCopyBlobFromUriResult on successfully aborting.
578  {
579  BlobRestClient::Blob::AbortCopyBlobFromUriOptions protocolLayerOptions;
580  protocolLayerOptions.CopyId = copyId;
581  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
582  return BlobRestClient::Blob::AbortCopyFromUri(
583  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
584  }

◆ AcquireLease()

Azure::Core::Response< AcquireBlobLeaseResult > Azure::Storage::Blobs::BlobClient::AcquireLease ( const std::string &  proposedLeaseId,
int32_t  duration,
const AcquireBlobLeaseOptions options = AcquireBlobLeaseOptions() 
) const

Acquires a lease on the blob.

Parameters
proposedLeaseIdProposed lease ID, in a GUID string format.
durationSpecifies the duration of the lease, in seconds, or Azure::Storage::c_InfiniteLeaseDuration for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change.
optionsOptional parameters to execute this function.
Returns
A AcquireBlobLeaseResult describing the lease.
634  {
635  BlobRestClient::Blob::AcquireBlobLeaseOptions protocolLayerOptions;
636  protocolLayerOptions.ProposedLeaseId = proposedLeaseId;
637  protocolLayerOptions.LeaseDuration = duration;
638  protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
639  protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
640  protocolLayerOptions.IfMatch = options.IfMatch;
641  protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
642  protocolLayerOptions.IfTags = options.TagConditions;
643  return BlobRestClient::Blob::AcquireLease(
644  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
645  }

◆ BreakLease()

Azure::Core::Response< BreakBlobLeaseResult > Azure::Storage::Blobs::BlobClient::BreakLease ( const BreakBlobLeaseOptions options = BreakBlobLeaseOptions()) const

Breaks the previously-acquired lease.

Parameters
optionsOptional parameters to execute this function.
Returns
A BreakBlobLeaseResult describing the broken lease.
696  {
697  BlobRestClient::Blob::BreakBlobLeaseOptions protocolLayerOptions;
698  protocolLayerOptions.BreakPeriod = options.breakPeriod;
699  protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
700  protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
701  protocolLayerOptions.IfMatch = options.IfMatch;
702  protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
703  protocolLayerOptions.IfTags = options.TagConditions;
704  return BlobRestClient::Blob::BreakLease(
705  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
706  }

◆ ChangeLease()

Azure::Core::Response< ChangeBlobLeaseResult > Azure::Storage::Blobs::BlobClient::ChangeLease ( const std::string &  leaseId,
const std::string &  proposedLeaseId,
const ChangeBlobLeaseOptions options = ChangeBlobLeaseOptions() 
) const

Changes the lease of an active lease.

Parameters
leaseIdID of the previously-acquired lease.
proposedLeaseIdProposed lease ID, in a GUID string format.
optionsOptional parameters to execute this function.
Returns
A ChangeBlobLeaseResult describing the lease.
681  {
682  BlobRestClient::Blob::ChangeBlobLeaseOptions protocolLayerOptions;
683  protocolLayerOptions.LeaseId = leaseId;
684  protocolLayerOptions.ProposedLeaseId = proposedLeaseId;
685  protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
686  protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
687  protocolLayerOptions.IfMatch = options.IfMatch;
688  protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
689  protocolLayerOptions.IfTags = options.TagConditions;
690  return BlobRestClient::Blob::ChangeLease(
691  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
692  }

◆ CreateFromConnectionString()

BlobClient Azure::Storage::Blobs::BlobClient::CreateFromConnectionString ( const std::string &  connectionString,
const std::string &  containerName,
const std::string &  blobName,
const BlobClientOptions options = BlobClientOptions() 
)
static

Initialize a new instance of BlobClient.

Parameters
connectionStringA connection string includes the authentication information required for your application to access data in an Azure Storage account at runtime.
containerNameThe name of the container containing this blob.
blobNameThe name of this blob.
optionsOptional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
Returns
A new BlobClient instance.
27  {
28  auto parsedConnectionString = Details::ParseConnectionString(connectionString);
29  auto blobUri = std::move(parsedConnectionString.BlobServiceUri);
30  blobUri.AppendPath(containerName, true);
31  blobUri.AppendPath(blobName, true);
32 
33  if (parsedConnectionString.KeyCredential)
34  {
35  return BlobClient(blobUri.GetAbsoluteUrl(), parsedConnectionString.KeyCredential, options);
36  }
37  else
38  {
39  return BlobClient(blobUri.GetAbsoluteUrl(), options);
40  }
41  }

◆ CreateSnapshot()

Azure::Core::Response< CreateBlobSnapshotResult > Azure::Storage::Blobs::BlobClient::CreateSnapshot ( const CreateBlobSnapshotOptions options = CreateBlobSnapshotOptions()) const

Creates a read-only snapshot of a blob.

Parameters
optionsOptional parameters to execute this function.
Returns
A CreateBlobSnapshotResult describing the new blob snapshot.
588  {
589  BlobRestClient::Blob::CreateBlobSnapshotOptions protocolLayerOptions;
590  protocolLayerOptions.Metadata = options.Metadata;
591  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
592  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
593  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
594  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
595  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
596  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
597  if (m_customerProvidedKey.HasValue())
598  {
599  protocolLayerOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
600  protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
601  protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
602  }
603  protocolLayerOptions.EncryptionScope = m_encryptionScope;
604  return BlobRestClient::Blob::CreateSnapshot(
605  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
606  }

◆ Delete()

Azure::Core::Response< DeleteBlobResult > Azure::Storage::Blobs::BlobClient::Delete ( const DeleteBlobOptions options = DeleteBlobOptions()) const

Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using DeleteBlobOptions.DeleteSnapshots.

Parameters
optionsOptional parameters to execute this function.
Returns
A DeleteBlobResult on successfully deleting.
609  {
610  BlobRestClient::Blob::DeleteBlobOptions protocolLayerOptions;
611  protocolLayerOptions.DeleteSnapshots = options.DeleteSnapshots;
612  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
613  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
614  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
615  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
616  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
617  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
618  return BlobRestClient::Blob::Delete(
619  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
620  }

◆ Download()

Azure::Core::Response< DownloadBlobResult > Azure::Storage::Blobs::BlobClient::Download ( const DownloadBlobOptions options = DownloadBlobOptions()) const

Downloads a blob or a blob range from the service, including its metadata and properties.

Parameters
optionsOptional parameters to execute this function.
Returns
A DownloadBlobResult describing the downloaded blob. BlobDownloadResponse.BodyStream contains the blob's data.
159  {
160  BlobRestClient::Blob::DownloadBlobOptions protocolLayerOptions;
161  if (options.Offset.HasValue() && options.Length.HasValue())
162  {
163  protocolLayerOptions.Range = std::make_pair(
164  options.Offset.GetValue(), options.Offset.GetValue() + options.Length.GetValue() - 1);
165  }
166  else if (options.Offset.HasValue())
167  {
168  protocolLayerOptions.Range = std::make_pair(
169  options.Offset.GetValue(),
170  std::numeric_limits<std::remove_reference_t<decltype(options.Offset.GetValue())>>::max());
171  }
172  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
173  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
174  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
175  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
176  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
177  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
178  if (m_customerProvidedKey.HasValue())
179  {
180  protocolLayerOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
181  protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
182  protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
183  }
184 
185  auto downloadResponse = BlobRestClient::Blob::Download(
186  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
187 
188  {
189  // In case network failure during reading the body
190  std::string eTag = downloadResponse->ETag;
191 
192  auto retryFunction
193  = [this, options, eTag](
194  const Azure::Core::Context& context,
195  const HttpGetterInfo& retryInfo) -> std::unique_ptr<Azure::Core::Http::BodyStream> {
196  unused(context);
197 
198  DownloadBlobOptions newOptions = options;
199  newOptions.Offset
200  = (options.Offset.HasValue() ? options.Offset.GetValue() : 0) + retryInfo.Offset;
201  newOptions.Length = options.Length;
202  if (newOptions.Length.HasValue())
203  {
204  newOptions.Length = options.Length.GetValue() - retryInfo.Offset;
205  }
206  if (!newOptions.AccessConditions.IfMatch.HasValue())
207  {
208  newOptions.AccessConditions.IfMatch = eTag;
209  }
210  return std::move(Download(newOptions)->BodyStream);
211  };
212 
213  ReliableStreamOptions reliableStreamOptions;
214  reliableStreamOptions.MaxRetryRequests = Details::c_reliableStreamRetryCount;
215  downloadResponse->BodyStream = std::make_unique<ReliableStream>(
216  std::move(downloadResponse->BodyStream), reliableStreamOptions, retryFunction);
217  }
218  return downloadResponse;
219  }

◆ DownloadTo() [1/2]

Azure::Core::Response< DownloadBlobToResult > Azure::Storage::Blobs::BlobClient::DownloadTo ( const std::string &  file,
const DownloadBlobToOptions options = DownloadBlobToOptions() 
) const

Downloads a blob or a blob range from the service to a file using parallel requests.

Parameters
fileA file path to write the downloaded content to.
optionsOptional parameters to execute this function.
Returns
A DownloadBlobToResult describing the downloaded blob.
348  {
349  constexpr int64_t c_defaultChunkSize = 4 * 1024 * 1024;
350 
351  // Just start downloading using an initial chunk. If it's a small blob, we'll get the whole
352  // thing in one shot. If it's a large blob, we'll get its full size in Content-Range and can
353  // keep downloading it in chunks.
354  int64_t firstChunkOffset = options.Offset.HasValue() ? options.Offset.GetValue() : 0;
355  int64_t firstChunkLength = c_defaultChunkSize;
356  if (options.InitialChunkSize.HasValue())
357  {
358  firstChunkLength = options.InitialChunkSize.GetValue();
359  }
360  if (options.Length.HasValue())
361  {
362  firstChunkLength = std::min(firstChunkLength, options.Length.GetValue());
363  }
364 
365  DownloadBlobOptions firstChunkOptions;
366  firstChunkOptions.Context = options.Context;
367  firstChunkOptions.Offset = options.Offset;
368  if (firstChunkOptions.Offset.HasValue())
369  {
370  firstChunkOptions.Length = firstChunkLength;
371  }
372 
373  Details::FileWriter fileWriter(file);
374 
375  auto firstChunk = Download(firstChunkOptions);
376 
377  int64_t blobSize;
378  int64_t blobRangeSize;
379  if (firstChunkOptions.Offset.HasValue())
380  {
381  blobSize = std::stoll(firstChunk->ContentRange.GetValue().substr(
382  firstChunk->ContentRange.GetValue().find('/') + 1));
383  blobRangeSize = blobSize - firstChunkOffset;
384  if (options.Length.HasValue())
385  {
386  blobRangeSize = std::min(blobRangeSize, options.Length.GetValue());
387  }
388  }
389  else
390  {
391  blobSize = firstChunk->BodyStream->Length();
392  blobRangeSize = blobSize;
393  }
394  firstChunkLength = std::min(firstChunkLength, blobRangeSize);
395 
396  auto bodyStreamToFile = [](Azure::Core::Http::BodyStream& stream,
397  Details::FileWriter& fileWriter,
398  int64_t offset,
399  int64_t length,
400  Azure::Core::Context& context) {
401  constexpr std::size_t bufferSize = 4 * 1024 * 1024;
402  std::vector<uint8_t> buffer(bufferSize);
403  while (length > 0)
404  {
405  int64_t readSize = std::min(static_cast<int64_t>(bufferSize), length);
406  int64_t bytesRead
407  = Azure::Core::Http::BodyStream::ReadToCount(context, stream, buffer.data(), readSize);
408  if (bytesRead != readSize)
409  {
410  throw std::runtime_error("error when reading body stream");
411  }
412  fileWriter.Write(buffer.data(), bytesRead, offset);
413  length -= bytesRead;
414  offset += bytesRead;
415  }
416  };
417 
418  bodyStreamToFile(
419  *(firstChunk->BodyStream), fileWriter, 0, firstChunkLength, firstChunkOptions.Context);
420  firstChunk->BodyStream.reset();
421 
422  auto returnTypeConverter = [](Azure::Core::Response<DownloadBlobResult>& response) {
423  DownloadBlobToResult ret;
424  ret.ETag = std::move(response->ETag);
425  ret.LastModified = std::move(response->LastModified);
426  ret.HttpHeaders = std::move(response->HttpHeaders);
427  ret.Metadata = std::move(response->Metadata);
428  ret.BlobType = response->BlobType;
429  ret.ServerEncrypted = response->ServerEncrypted;
430  ret.EncryptionKeySha256 = std::move(response->EncryptionKeySha256);
431  return Azure::Core::Response<DownloadBlobToResult>(
432  std::move(ret),
433  std::make_unique<Azure::Core::Http::RawResponse>(std::move(response.GetRawResponse())));
434  };
435  auto ret = returnTypeConverter(firstChunk);
436 
437  // Keep downloading the remaining in parallel
438  auto downloadChunkFunc
439  = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
440  DownloadBlobOptions chunkOptions;
441  chunkOptions.Context = options.Context;
442  chunkOptions.Offset = offset;
443  chunkOptions.Length = length;
444  auto chunk = Download(chunkOptions);
445  bodyStreamToFile(
446  *(chunk->BodyStream),
447  fileWriter,
448  offset - firstChunkOffset,
449  chunkOptions.Length.GetValue(),
450  chunkOptions.Context);
451 
452  if (chunkId == numChunks - 1)
453  {
454  ret = returnTypeConverter(chunk);
455  }
456  };
457 
458  int64_t remainingOffset = firstChunkOffset + firstChunkLength;
459  int64_t remainingSize = blobRangeSize - firstChunkLength;
460  int64_t chunkSize;
461  if (options.ChunkSize.HasValue())
462  {
463  chunkSize = options.ChunkSize.GetValue();
464  }
465  else
466  {
467  int64_t c_grainSize = 4 * 1024;
468  chunkSize = remainingSize / options.Concurrency;
469  chunkSize = (std::max(chunkSize, int64_t(1)) + c_grainSize - 1) / c_grainSize * c_grainSize;
470  chunkSize = std::min(chunkSize, c_defaultChunkSize);
471  }
472 
473  Details::ConcurrentTransfer(
474  remainingOffset, remainingSize, chunkSize, options.Concurrency, downloadChunkFunc);
475  ret->ContentLength = blobRangeSize;
476  return ret;
477  }

◆ DownloadTo() [2/2]

Azure::Core::Response< DownloadBlobToResult > Azure::Storage::Blobs::BlobClient::DownloadTo ( uint8_t *  buffer,
std::size_t  bufferSize,
const DownloadBlobToOptions options = DownloadBlobToOptions() 
) const

Downloads a blob or a blob range from the service to a memory buffer using parallel requests.

Parameters
bufferA memory buffer to write the blob content to.
bufferSizeSize of the memory buffer. Size must be larger or equal to size of the blob or blob range.
optionsOptional parameters to execute this function.
Returns
A DownloadBlobToResult describing the downloaded blob.
225  {
226  constexpr int64_t c_defaultChunkSize = 4 * 1024 * 1024;
227 
228  // Just start downloading using an initial chunk. If it's a small blob, we'll get the whole
229  // thing in one shot. If it's a large blob, we'll get its full size in Content-Range and can
230  // keep downloading it in chunks.
231  int64_t firstChunkOffset = options.Offset.HasValue() ? options.Offset.GetValue() : 0;
232  int64_t firstChunkLength = c_defaultChunkSize;
233  if (options.InitialChunkSize.HasValue())
234  {
235  firstChunkLength = options.InitialChunkSize.GetValue();
236  }
237  if (options.Length.HasValue())
238  {
239  firstChunkLength = std::min(firstChunkLength, options.Length.GetValue());
240  }
241 
242  DownloadBlobOptions firstChunkOptions;
243  firstChunkOptions.Context = options.Context;
244  firstChunkOptions.Offset = options.Offset;
245  if (firstChunkOptions.Offset.HasValue())
246  {
247  firstChunkOptions.Length = firstChunkLength;
248  }
249 
250  auto firstChunk = Download(firstChunkOptions);
251 
252  int64_t blobSize;
253  int64_t blobRangeSize;
254  if (firstChunkOptions.Offset.HasValue())
255  {
256  blobSize = std::stoll(firstChunk->ContentRange.GetValue().substr(
257  firstChunk->ContentRange.GetValue().find('/') + 1));
258  blobRangeSize = blobSize - firstChunkOffset;
259  if (options.Length.HasValue())
260  {
261  blobRangeSize = std::min(blobRangeSize, options.Length.GetValue());
262  }
263  }
264  else
265  {
266  blobSize = firstChunk->BodyStream->Length();
267  blobRangeSize = blobSize;
268  }
269  firstChunkLength = std::min(firstChunkLength, blobRangeSize);
270 
271  if (static_cast<std::size_t>(blobRangeSize) > bufferSize)
272  {
273  throw std::runtime_error(
274  "buffer is not big enough, blob range size is " + std::to_string(blobRangeSize));
275  }
276 
277  int64_t bytesRead = Azure::Core::Http::BodyStream::ReadToCount(
278  firstChunkOptions.Context, *(firstChunk->BodyStream), buffer, firstChunkLength);
279  if (bytesRead != firstChunkLength)
280  {
281  throw std::runtime_error("error when reading body stream");
282  }
283  firstChunk->BodyStream.reset();
284 
285  auto returnTypeConverter = [](Azure::Core::Response<DownloadBlobResult>& response) {
286  DownloadBlobToResult ret;
287  ret.ETag = std::move(response->ETag);
288  ret.LastModified = std::move(response->LastModified);
289  ret.HttpHeaders = std::move(response->HttpHeaders);
290  ret.Metadata = std::move(response->Metadata);
291  ret.BlobType = response->BlobType;
292  ret.ServerEncrypted = response->ServerEncrypted;
293  ret.EncryptionKeySha256 = std::move(response->EncryptionKeySha256);
294  return Azure::Core::Response<DownloadBlobToResult>(
295  std::move(ret),
296  std::make_unique<Azure::Core::Http::RawResponse>(std::move(response.GetRawResponse())));
297  };
298  auto ret = returnTypeConverter(firstChunk);
299 
300  // Keep downloading the remaining in parallel
301  auto downloadChunkFunc
302  = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
303  DownloadBlobOptions chunkOptions;
304  chunkOptions.Context = options.Context;
305  chunkOptions.Offset = offset;
306  chunkOptions.Length = length;
307  auto chunk = Download(chunkOptions);
308  int64_t bytesRead = Azure::Core::Http::BodyStream::ReadToCount(
309  chunkOptions.Context,
310  *(chunk->BodyStream),
311  buffer + (offset - firstChunkOffset),
312  chunkOptions.Length.GetValue());
313  if (bytesRead != chunkOptions.Length.GetValue())
314  {
315  throw std::runtime_error("error when reading body stream");
316  }
317 
318  if (chunkId == numChunks - 1)
319  {
320  ret = returnTypeConverter(chunk);
321  }
322  };
323 
324  int64_t remainingOffset = firstChunkOffset + firstChunkLength;
325  int64_t remainingSize = blobRangeSize - firstChunkLength;
326  int64_t chunkSize;
327  if (options.ChunkSize.HasValue())
328  {
329  chunkSize = options.ChunkSize.GetValue();
330  }
331  else
332  {
333  int64_t c_grainSize = 4 * 1024;
334  chunkSize = remainingSize / options.Concurrency;
335  chunkSize = (std::max(chunkSize, int64_t(1)) + c_grainSize - 1) / c_grainSize * c_grainSize;
336  chunkSize = std::min(chunkSize, c_defaultChunkSize);
337  }
338 
339  Details::ConcurrentTransfer(
340  remainingOffset, remainingSize, chunkSize, options.Concurrency, downloadChunkFunc);
341  ret->ContentLength = blobRangeSize;
342  return ret;
343  }

◆ GetAppendBlobClient()

AppendBlobClient Azure::Storage::Blobs::BlobClient::GetAppendBlobClient ( ) const

Creates a new AppendBlobClient object with the same uri as this BlobClient. The new AppendBlobClient uses the same request policy pipeline as this BlobClient.

Returns
A new AppendBlobClient instance.
125 { return AppendBlobClient(*this); }

◆ GetBlockBlobClient()

BlockBlobClient Azure::Storage::Blobs::BlobClient::GetBlockBlobClient ( ) const

Creates a new BlockBlobClient object with the same uri as this BlobClient. The new BlockBlobClient uses the same request policy pipeline as this BlobClient.

Returns
A new BlockBlobClient instance.
123 { return BlockBlobClient(*this); }

◆ GetPageBlobClient()

PageBlobClient Azure::Storage::Blobs::BlobClient::GetPageBlobClient ( ) const

Creates a new PageBlobClient object with the same uri as this BlobClient. The new PageBlobClient uses the same request policy pipeline as this BlobClient.

Returns
A new PageBlobClient instance.
127 { return PageBlobClient(*this); }

◆ GetProperties()

Azure::Core::Response< GetBlobPropertiesResult > Azure::Storage::Blobs::BlobClient::GetProperties ( const GetBlobPropertiesOptions options = GetBlobPropertiesOptions()) const

Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

Parameters
optionsOptional parameters to execute this function.
Returns
A GetBlobPropertiesResult describing the blob's properties.
481  {
482  BlobRestClient::Blob::GetBlobPropertiesOptions protocolLayerOptions;
483  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
484  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
485  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
486  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
487  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
488  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
489  if (m_customerProvidedKey.HasValue())
490  {
491  protocolLayerOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
492  protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
493  protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
494  }
495  return BlobRestClient::Blob::GetProperties(
496  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
497  }

◆ GetTags()

Azure::Core::Response< GetBlobTagsResult > Azure::Storage::Blobs::BlobClient::GetTags ( const GetBlobTagsOptions options = GetBlobTagsOptions()) const

Gets the tags associated with the underlying blob.

Parameters
optionsOptional parameters to execute this function.
Returns
Tags on successfully getting tags.
721  {
722  BlobRestClient::Blob::GetBlobTagsOptions protocolLayerOptions;
723  protocolLayerOptions.IfTags = options.TagConditions;
724  return BlobRestClient::Blob::GetTags(
725  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
726  }

◆ GetUri()

std::string Azure::Storage::Blobs::BlobClient::GetUri ( ) const
inline

Gets the blob's primary uri endpoint.

Returns
The blob's primary uri endpoint.
120 { return m_blobUrl.GetAbsoluteUrl(); }

◆ ReleaseLease()

Azure::Core::Response< ReleaseBlobLeaseResult > Azure::Storage::Blobs::BlobClient::ReleaseLease ( const std::string &  leaseId,
const ReleaseBlobLeaseOptions options = ReleaseBlobLeaseOptions() 
) const

Releases the blob's previously-acquired lease.

Parameters
leaseIdID of the previously-acquired lease.
optionsOptional parameters to execute this function.
Returns
A ReleaseBlobLeaseResult describing the updated container.
665  {
666  BlobRestClient::Blob::ReleaseBlobLeaseOptions protocolLayerOptions;
667  protocolLayerOptions.LeaseId = leaseId;
668  protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
669  protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
670  protocolLayerOptions.IfMatch = options.IfMatch;
671  protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
672  protocolLayerOptions.IfTags = options.TagConditions;
673  return BlobRestClient::Blob::ReleaseLease(
674  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
675  }

◆ RenewLease()

Azure::Core::Response< RenewBlobLeaseResult > Azure::Storage::Blobs::BlobClient::RenewLease ( const std::string &  leaseId,
const RenewBlobLeaseOptions options = RenewBlobLeaseOptions() 
) const

Renews the blob's previously-acquired lease.

Parameters
leaseIdID of the previously-acquired lease.
optionsOptional parameters to execute this function.
Returns
A RenewBlobLeaseResult describing the lease.
650  {
651  BlobRestClient::Blob::RenewBlobLeaseOptions protocolLayerOptions;
652  protocolLayerOptions.LeaseId = leaseId;
653  protocolLayerOptions.IfModifiedSince = options.IfModifiedSince;
654  protocolLayerOptions.IfUnmodifiedSince = options.IfUnmodifiedSince;
655  protocolLayerOptions.IfMatch = options.IfMatch;
656  protocolLayerOptions.IfNoneMatch = options.IfNoneMatch;
657  protocolLayerOptions.IfTags = options.TagConditions;
658  return BlobRestClient::Blob::RenewLease(
659  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
660  }

◆ SetAccessTier()

Azure::Core::Response< SetBlobAccessTierResult > Azure::Storage::Blobs::BlobClient::SetAccessTier ( AccessTier  Tier,
const SetBlobAccessTierOptions options = SetBlobAccessTierOptions() 
) const

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage or general purpose v2 account.

Parameters
TierIndicates the tier to be set on the blob.
optionsOptional parameters to execute this function.
Returns
A SetBlobAccessTierResult on successfully setting the tier.
541  {
542  BlobRestClient::Blob::SetBlobAccessTierOptions protocolLayerOptions;
543  protocolLayerOptions.Tier = Tier;
544  protocolLayerOptions.RehydratePriority = options.RehydratePriority;
545  return BlobRestClient::Blob::SetAccessTier(
546  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
547  }

◆ SetHttpHeaders()

Azure::Core::Response< SetBlobHttpHeadersResult > Azure::Storage::Blobs::BlobClient::SetHttpHeaders ( BlobHttpHeaders  httpHeaders,
const SetBlobHttpHeadersOptions options = SetBlobHttpHeadersOptions() 
) const

Sets system properties on the blob.

Parameters
httpHeadersThe standard HTTP header system properties to set.
optionsOptional parameters to execute this function.
Returns
A SetBlobHttpHeadersResult describing the updated blob.
502  {
503  BlobRestClient::Blob::SetBlobHttpHeadersOptions protocolLayerOptions;
504  protocolLayerOptions.HttpHeaders = std::move(httpHeaders);
505  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
506  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
507  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
508  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
509  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
510  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
511  return BlobRestClient::Blob::SetHttpHeaders(
512  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
513  }

◆ SetMetadata()

Azure::Core::Response< SetBlobMetadataResult > Azure::Storage::Blobs::BlobClient::SetMetadata ( std::map< std::string, std::string >  metadata,
const SetBlobMetadataOptions options = SetBlobMetadataOptions() 
) const

Sets user-defined metadata for the specified blob as one or more name-value pairs.

Parameters
metadataCustom metadata to set for this blob.
optionsOptional parameters to execute this function.
Returns
A SetBlobMetadataResult describing the updated blob.
518  {
519  BlobRestClient::Blob::SetBlobMetadataOptions protocolLayerOptions;
520  protocolLayerOptions.Metadata = std::move(metadata);
521  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
522  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
523  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
524  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
525  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
526  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
527  if (m_customerProvidedKey.HasValue())
528  {
529  protocolLayerOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
530  protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
531  protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
532  }
533  protocolLayerOptions.EncryptionScope = m_encryptionScope;
534  return BlobRestClient::Blob::SetMetadata(
535  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
536  }

◆ SetTags()

Azure::Core::Response< SetBlobTagsResult > Azure::Storage::Blobs::BlobClient::SetTags ( std::map< std::string, std::string >  tags,
const SetBlobTagsOptions options = SetBlobTagsOptions() 
) const

Sets tags on the underlying blob.

Parameters
tagsThe tags to set on the blob.
optionsOptional parameters to execute this function.
Returns
A SetBlobTagsInfo on successfully setting tags.
711  {
712  BlobRestClient::Blob::SetBlobTagsOptions protocolLayerOptions;
713  protocolLayerOptions.Tags = std::move(tags);
714  protocolLayerOptions.IfTags = options.TagConditions;
715  return BlobRestClient::Blob::SetTags(
716  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
717  }

◆ StartCopyFromUri()

Azure::Core::Response< StartCopyBlobFromUriResult > Azure::Storage::Blobs::BlobClient::StartCopyFromUri ( const std::string &  sourceUri,
const StartCopyBlobFromUriOptions options = StartCopyBlobFromUriOptions() 
) const

Copies data at from the source to this blob.

Parameters
sourceUriSpecifies the uri of the source blob. The value may a uri of up to 2 KB in length that specifies a blob. A source blob in the same storage account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the copy operation.
optionsOptional parameters to execute this function.
Returns
A StartCopyBlobFromUriResult describing the state of the copy operation.
552  {
553  BlobRestClient::Blob::StartCopyBlobFromUriOptions protocolLayerOptions;
554  protocolLayerOptions.Metadata = options.Metadata;
555  protocolLayerOptions.SourceUri = sourceUri;
556  protocolLayerOptions.Tier = options.Tier;
557  protocolLayerOptions.RehydratePriority = options.RehydratePriority;
558  protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
559  protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
560  protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
561  protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
562  protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
563  protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
564  protocolLayerOptions.SourceLeaseId = options.SourceConditions.LeaseId;
565  protocolLayerOptions.SourceIfModifiedSince = options.SourceConditions.IfModifiedSince;
566  protocolLayerOptions.SourceIfUnmodifiedSince = options.SourceConditions.IfUnmodifiedSince;
567  protocolLayerOptions.SourceIfMatch = options.SourceConditions.IfMatch;
568  protocolLayerOptions.SourceIfNoneMatch = options.SourceConditions.IfNoneMatch;
569  protocolLayerOptions.ShouldSealDestination = options.ShouldSealDestination;
570  protocolLayerOptions.SourceIfTags = options.SourceConditions.TagConditions;
571  return BlobRestClient::Blob::StartCopyFromUri(
572  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
573  }

◆ Undelete()

Azure::Core::Response< UndeleteBlobResult > Azure::Storage::Blobs::BlobClient::Undelete ( const UndeleteBlobOptions options = UndeleteBlobOptions()) const

Restores the contents and metadata of a soft deleted blob and any associated soft deleted snapshots.

Parameters
optionsOptional parameters to execute this function.
Returns
A UndeleteBlobResult on successfully deleting.
624  {
625  BlobRestClient::Blob::UndeleteBlobOptions protocolLayerOptions;
626  return BlobRestClient::Blob::Undelete(
627  options.Context, *m_pipeline, m_blobUrl, protocolLayerOptions);
628  }

◆ WithSnapshot()

BlobClient Azure::Storage::Blobs::BlobClient::WithSnapshot ( const std::string &  snapshot) const

Initializes a new instance of the BlobClient class with an identical uri source but the specified snapshot timestamp.

Parameters
snapshotThe snapshot identifier.
Returns
A new BlobClient instance.
Remarks
Pass empty string to remove the snapshot returning the base blob.
130  {
131  BlobClient newClient(*this);
132  if (snapshot.empty())
133  {
134  newClient.m_blobUrl.RemoveQuery(Details::c_HttpQuerySnapshot);
135  }
136  else
137  {
138  newClient.m_blobUrl.AppendQuery(Details::c_HttpQuerySnapshot, snapshot);
139  }
140  return newClient;
141  }

◆ WithVersionId()

BlobClient Azure::Storage::Blobs::BlobClient::WithVersionId ( const std::string &  versionId) const

Creates a clone of this instance that references a version ID rather than the base blob.

Parameters
versionIdThe version ID returning a URL to the base blob.
Returns
A new BlobClient instance.
Remarks
Pass empty string to remove the version ID returning the base blob.
144  {
145  BlobClient newClient(*this);
146  if (versionId.empty())
147  {
148  newClient.m_blobUrl.RemoveQuery(Details::c_HttpQueryVersionId);
149  }
150  else
151  {
152  newClient.m_blobUrl.AppendQuery(Details::c_HttpQueryVersionId, versionId);
153  }
154  return newClient;
155  }

The documentation for this class was generated from the following files:
Azure::Storage::Blobs::BlobClient::Download
Azure::Core::Response< DownloadBlobResult > Download(const DownloadBlobOptions &options=DownloadBlobOptions()) const
Downloads a blob or a blob range from the service, including its metadata and properties.
Definition: blob_client.cpp:157
Azure::Storage::Blobs::BlobClient::BlobClient
BlobClient(const std::string &blobUri, std::shared_ptr< SharedKeyCredential > credential, const BlobClientOptions &options=BlobClientOptions())
Initialize a new instance of BlobClient.
Definition: blob_client.cpp:43