From c60ee6c8bc09245e35ba06e8c1a2ee6eb634276e Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 24 Aug 2020 00:00:31 +0800 Subject: [PATCH 1/2] Update upload.go --- upload/upload.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/upload/upload.go b/upload/upload.go index 4478b893..ca0d2cdb 100644 --- a/upload/upload.go +++ b/upload/upload.go @@ -1,6 +1,7 @@ package upload import ( + "bytes" "errors" "fmt" "io" @@ -86,13 +87,13 @@ L: // req := &concurrent.Request{ Work: func() error { - err := cxt.BlobServiceClient.PutPage(cxt.ContainerName, - cxt.BlobName, - dataWithRange.Range.Start, - dataWithRange.Range.End, - storage.PageWriteTypeUpdate, - dataWithRange.Data, - nil) + container := cxt.BlobServiceClient.GetContainerReference(cxt.ContainerName) + blob := container.GetBlobReference(cxt.BlobName) + + err := blob.WriteRange(storage.BlobRange{ + Start: uint64(dataWithRange.Range.Start), + End: uint64(dataWithRange.Range.End), + }, bytes.NewReader(dataWithRange.Data), nil) if err == nil { uploadProgress.ReportBytesProcessedCount(dataWithRange.Range.Length()) } From 9c26e604d2401fb333660a9704c55bc628be3d25 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 24 Aug 2020 00:01:10 +0800 Subject: [PATCH 2/2] Update metaData.go --- upload/metadata/metaData.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upload/metadata/metaData.go b/upload/metadata/metaData.go index 6bfcf5c4..01b8bd8f 100644 --- a/upload/metadata/metaData.go +++ b/upload/metadata/metaData.go @@ -92,11 +92,11 @@ func NewMetaDataFromLocalVHD(vhdPath string) (*MetaData, error) { // MetaData associated with the blob it returns nil value for MetaData // func NewMetadataFromBlob(blobClient storage.BlobStorageClient, containerName, blobName string) (*MetaData, error) { - allMetadata, err := blobClient.GetBlobMetadata(containerName, blobName) - if err != nil { + blob := blobClient.GetContainerReference(containerName).GetBlobReference(blobName) + if err := blob.GetMetadata(nil); err != nil { return nil, fmt.Errorf("NewMetadataFromBlob, failed to fetch blob metadata: %v", err) } - m, ok := allMetadata[metaDataKey] + m, ok := blob.Metadata[metaDataKey] if !ok { return nil, nil }