diff --git a/sdk/storage/azure-storage-blobs/CHANGELOG.md b/sdk/storage/azure-storage-blobs/CHANGELOG.md index 627c55176..3755f555e 100644 --- a/sdk/storage/azure-storage-blobs/CHANGELOG.md +++ b/sdk/storage/azure-storage-blobs/CHANGELOG.md @@ -7,6 +7,7 @@ - Added `RequestId` in API return types. - Added some new properties in `GetBlobPropertiesResult`, `DownloadBlobResult` and `DownloadBlobToResult`. - Added `RangeHashAlgorithm` in `DownloadBlobOptions`. +- Added `UploadBlob` in `BlobContainerClient`. ### Breaking Changes diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp index dfa2f0171..1a74d7218 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp @@ -257,6 +257,21 @@ namespace Azure { namespace Storage { namespace Blobs { const std::string& blobName, const DeleteBlobOptions& options = DeleteBlobOptions()) const; + /** + * @brief Creates a new block blob under this container. For partial block blob updates and + * other advanced features, please see BlockBlobClient. To create or modify page or see + * PageBlobClient or AppendBlobClient. + * + * @param blobName The name of the blob to create. + * @param content A BodyStream containing the content to upload. + * @param options Optional parameters to execute this function. + * @return A BlockBlobClient referencing the newly created block blob. + */ + Azure::Core::Response UploadBlob( + const std::string& blobName, + Azure::Core::Http::BodyStream* content, + const UploadBlockBlobOptions& options = UploadBlockBlobOptions()) const; + private: Azure::Core::Http::Url m_blobContainerUrl; std::shared_ptr m_pipeline; diff --git a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp index fff7325b7..d9695bcde 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp @@ -312,4 +312,15 @@ namespace Azure { namespace Storage { namespace Blobs { return Azure::Core::Response(response.ExtractRawResponse()); } + Azure::Core::Response BlobContainerClient::UploadBlob( + const std::string& blobName, + Azure::Core::Http::BodyStream* content, + const UploadBlockBlobOptions& options) const + { + auto blockBlobClient = GetBlockBlobClient(blobName); + auto response = blockBlobClient.Upload(content, options); + return Azure::Core::Response( + std::move(blockBlobClient), response.ExtractRawResponse()); + } + }}} // namespace Azure::Storage::Blobs