Add BlobContainerClient::UploadBlob (#1532)

* Add BlobContainerClient::UploadBlob

* changelog
This commit is contained in:
JinmingHu 2021-02-01 17:50:25 +08:00 committed by GitHub
parent 721473a568
commit ce189c1d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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<BlockBlobClient> 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<Azure::Core::Http::HttpPipeline> m_pipeline;

View File

@ -312,4 +312,15 @@ namespace Azure { namespace Storage { namespace Blobs {
return Azure::Core::Response<void>(response.ExtractRawResponse());
}
Azure::Core::Response<BlockBlobClient> 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<BlockBlobClient>(
std::move(blockBlobClient), response.ExtractRawResponse());
}
}}} // namespace Azure::Storage::Blobs