CreateBlob Method

Creates a new blob of the specified type.

Syntax

int CreateBlob(const QString& qsBlob, int iBlobType, qint64 lPageBlobSize);

Remarks

This method creates a new blob named Blob in the container currently selected by Container. BlobType specifies what type of blob should be created; valid values are: Possible values are:

abtBlockBlob (0) Block blob
abtPageBlob (1) Page blob
abtAppendBlob (2) Append blob

Refer to Azure's Understanding block blobs, append blobs, and page blobs article for more information about blob types.

PageBlobSize is only used when BlobType is abtPageBlob (1); it is ignored otherwise.

If the specified blob already exists, and is the same type of blob as BlobType specifies, then it will be overwritten if Overwrite is enabled. However, any snapshots associated with the existing blob are retained.

If the specified blob already exists and has an active lease, its lease Id must be specified using LeaseId, or the request will fail.

If the SendMetadata configuration setting is enabled when this method is called, all items in the Metadata* properties will be sent along with the creation request.

Creating Block Blobs

Block blobs can be created either with or without data initially. In either case, after the block blob is created, its contents can be managed by uploading blocks with PutBlock and then committing a new block list using PutBlockList.

If upload data is present when this method is called to create a block blob, it will be uploaded in one of two ways. If the amount of data provided is less than or equal to the limit specified by the SimpleUploadLimit configuration setting (268435456 bytes (256MB), by default), it will be uploaded directly in the create blob request.

If more than SimpleUploadLimit bytes of data are provided, the class will first create the new block blob, and then upload the data by splitting it up into blocks (sized according to the FragmentSize configuration setting), uploading them individually, and then committing a new block list. To accomplish this, the class automatically makes calls to PutBlock and PutBlockList internally, tracks the blocks as they are uploaded using the Block* properties, and tracks how much data has been uploaded using the StartByte property. The FragmentComplete event will fire after each block is uploaded.

If, during a block-based upload, any individual PutBlock request (or the PutBlockList request) fails, the upload can be resumed be calling this method again with the same parameters, so long as the Block* and StartByte properties still hold the same information as they did when the upload was interrupted.

When a block-based upload completes successfully, StartByte is reset to 0, but the Block* properties remains populated. This allows applications to easily inspect the Ids of the uploaded blocks, which the class generates automatically in the following GUID format: dddddddd-dddd-dddd-dddd-dddddddddddd (where each d is a single hex digit).

Creating Page Blobs

Unlike block blobs, no data can be uploaded when creating a page blob. However, the page blob's size (i.e., capacity) must be specified using PageBlobSize. A page blob's size must be a 512-byte-aligned; i.e. PageBlobSize % 512 == 0.

Once a page blob has been created, its contents can be manipulated using the PutPages and ClearPages methods.

Creating Append Blobs

Append blobs must also be created without uploading any data initially. After a page blob has been created, data can be appended to it using the AppendBlock method.

Error Handling

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Qt Edition - Version 20.0 [Build 8265]