Skip to content

Commit

Permalink
PutBlobFromURL/UploadBlobFromURL API (#20558)
Browse files Browse the repository at this point in the history
* Fresh PR for PutBlobFromURL

* Updating copy source auth test and resolving comment

* Fixing lint issues and recorded

* Adding recorded negative test for copy soure auth

* Updating test recordings

* Update sdk/storage/azblob/blockblob/client_test.go

Co-authored-by: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com>

* Cleaning up tests

* Updating expiry time to be shorter

---------

Co-authored-by: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com>
  • Loading branch information
siminsavani-msft and souravgupta-msft authored Apr 6, 2023
1 parent be3f449 commit 0a42300
Show file tree
Hide file tree
Showing 6 changed files with 736 additions and 1 deletion.
1 change: 1 addition & 0 deletions sdk/storage/azblob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Added [Blob Batch API](https://learn.microsoft.com/rest/api/storageservices/blob-batch).
* Added support for bearer challenge for identity based managed disks.
* Added support for GetAccountInfo to container and blob level clients.
* Added [UploadBlobFromURL API](https://learn.microsoft.com/rest/api/storageservices/put-blob-from-url).
* Added support for CopySourceAuthorization to appendblob.AppendBlockFromURL

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azblob/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azblob",
"Tag": "go/storage/azblob_fad5549316"
"Tag": "go/storage/azblob_cc6efe2d90"
}
13 changes: 13 additions & 0 deletions sdk/storage/azblob/blockblob/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ func (bb *Client) Upload(ctx context.Context, body io.ReadSeekCloser, options *U
return resp, err
}

// UploadBlobFromURL - The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from
// a given URL. Partial updates are not supported with Put Blob from URL; the content of an existing blob is overwritten
// with the content of the new blob. To perform partial updates to a block blob’s contents using a source URL, use the Put
// Block from URL API in conjunction with Put Block List.
// For more information, see https://learn.microsoft.com/rest/api/storageservices/put-blob-from-url
func (bb *Client) UploadBlobFromURL(ctx context.Context, copySource string, options *UploadBlobFromURLOptions) (UploadBlobFromURLResponse, error) {
opts, httpHeaders, leaseAccessConditions, cpkInfo, cpkSourceInfo, modifiedAccessConditions, sourceModifiedConditions := options.format()

resp, err := bb.generated().PutBlobFromURL(ctx, int64(0), copySource, opts, httpHeaders, leaseAccessConditions, cpkInfo, cpkSourceInfo, modifiedAccessConditions, sourceModifiedConditions)

return resp, err
}

// StageBlock uploads the specified block to the block blob's "staging area" to be later committed by a call to CommitBlockList.
// Note that the http client closes the body stream after the request is sent to the service.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-block.
Expand Down
Loading

0 comments on commit 0a42300

Please sign in to comment.