-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/storage/put blob from url #15978
Merged
seanmcc-msft
merged 10 commits into
Azure:feature/storage/stg75base
from
seanmcc-msft:feature/storage/putBlobFromURL
Nov 6, 2020
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
182f50c
Inital commit
seanmcc-msft 4fd35fc
fixed build
seanmcc-msft 7c13cbe
Added unit tests
seanmcc-msft 22ed3a1
Added some unit tests
seanmcc-msft da45e35
finished recording tests
seanmcc-msft 5832dc5
PR comments
seanmcc-msft ed63884
Merge branch 'feature/storage/stg75base' into feature/storage/putBlob…
seanmcc-msft 6dc5cbd
PR comments
seanmcc-msft 0ca0d91
PR comments
seanmcc-msft e00c037
PR comments
seanmcc-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2160,6 +2160,195 @@ private async Task<Stream> OpenWriteInternal( | |
} | ||
#endregion OpenWrite | ||
|
||
#region PutBlobFromUrl | ||
/// <summary> | ||
/// The Put Blob from URL operation creates a new Block Blob where the contents of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be updated to "The Upload From URL operation", or should we stick with what the REST API operation is called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
/// blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. | ||
/// | ||
/// 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. | ||
/// </summary> | ||
/// <param name="copySource"> | ||
/// Required. Specifies the URL of the source blob. he source blob may be of any type, | ||
amnguye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// including a block blob, append blob, or page blob.The value may be a URL of up to 2 | ||
/// KiB in length that specifies a blob. The value should be URL-encoded as it would appear | ||
/// in a request URI. The source blob must either be public or must be authorized via a | ||
/// shared access signature. If the source blob is public, no authorization is required | ||
/// to perform the operation. | ||
/// </param> | ||
/// <param name="options"> | ||
/// Optional parameters. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// Optional <see cref="CancellationToken"/> to propagate | ||
/// notifications that the operation should be cancelled. | ||
/// </param> | ||
/// <returns> | ||
/// A <see cref="Response{BlobContentInfo}"/> describing the | ||
/// state of the updated block blob. | ||
/// </returns> | ||
/// <remarks> | ||
/// A <see cref="RequestFailedException"/> will be thrown if | ||
/// a failure occurs. | ||
/// </remarks> | ||
public virtual Response<BlobContentInfo> PutBlobFromUrl( | ||
seanmcc-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uri copySource, | ||
BlobPutBlobFromUrlOptions options = default, | ||
CancellationToken cancellationToken = default) | ||
=> PutBlobFromUrlInternal( | ||
copySource, | ||
options, | ||
async: false, | ||
cancellationToken) | ||
.EnsureCompleted(); | ||
|
||
/// <summary> | ||
/// The Put Blob from URL operation creates a new Block Blob where the contents of the | ||
/// blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. | ||
/// | ||
/// 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. | ||
/// </summary> | ||
/// <param name="copySource"> | ||
/// Required. Specifies the URL of the source blob. he source blob may be of any type, | ||
/// including a block blob, append blob, or page blob.The value may be a URL of up to 2 | ||
/// KiB in length that specifies a blob. The value should be URL-encoded as it would appear | ||
/// in a request URI. The source blob must either be public or must be authorized via a | ||
/// shared access signature. If the source blob is public, no authorization is required | ||
/// to perform the operation. | ||
/// </param> | ||
/// <param name="options"> | ||
/// Optional parameters. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// Optional <see cref="CancellationToken"/> to propagate | ||
/// notifications that the operation should be cancelled. | ||
/// </param> | ||
/// <returns> | ||
/// A <see cref="Response{BlobContentInfo}"/> describing the | ||
/// state of the updated block blob. | ||
/// </returns> | ||
/// <remarks> | ||
/// A <see cref="RequestFailedException"/> will be thrown if | ||
/// a failure occurs. | ||
/// </remarks> | ||
public virtual async Task<Response<BlobContentInfo>> PutBlobFromUrlAsync( | ||
Uri copySource, | ||
BlobPutBlobFromUrlOptions options = default, | ||
CancellationToken cancellationToken = default) | ||
=> await PutBlobFromUrlInternal( | ||
copySource, | ||
options, | ||
async: true, | ||
cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
/// <summary> | ||
/// The Put Blob from URL operation creates a new Block Blob where the contents of the | ||
/// blob are read from a given URL. This API is supported beginning with the 2020-04-08 version. | ||
/// | ||
/// 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. | ||
/// </summary> | ||
/// <param name="copySource"> | ||
/// Required. Specifies the URL of the source blob. he source blob may be of any type, | ||
/// including a block blob, append blob, or page blob.The value may be a URL of up to 2 | ||
/// KiB in length that specifies a blob. The value should be URL-encoded as it would appear | ||
/// in a request URI. The source blob must either be public or must be authorized via a | ||
/// shared access signature. If the source blob is public, no authorization is required | ||
/// to perform the operation. | ||
/// </param> | ||
/// <param name="options"> | ||
/// Optional parameters. | ||
/// </param> | ||
/// <param name="async"> | ||
/// Whether to invoke the operation asynchronously. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// Optional <see cref="CancellationToken"/> to propagate | ||
/// notifications that the operation should be cancelled. | ||
/// </param> | ||
/// <returns> | ||
/// A <see cref="Response{BlobContentInfo}"/> describing the | ||
/// state of the updated block blob. | ||
/// </returns> | ||
/// <remarks> | ||
/// A <see cref="RequestFailedException"/> will be thrown if | ||
/// a failure occurs. | ||
/// </remarks> | ||
internal virtual async Task<Response<BlobContentInfo>> PutBlobFromUrlInternal( | ||
Uri copySource, | ||
BlobPutBlobFromUrlOptions options, | ||
bool async, | ||
CancellationToken cancellationToken) | ||
{ | ||
using (Pipeline.BeginLoggingScope(nameof(BlockBlobClient))) | ||
{ | ||
Pipeline.LogMethodEnter( | ||
nameof(BlockBlobClient), | ||
message: | ||
$"{nameof(Uri)}: {Uri}\n" + | ||
$"{nameof(options.HttpHeaders)}: {options?.HttpHeaders}\n" + | ||
$"{nameof(options.DestinationConditions)}: {options?.DestinationConditions}"); | ||
try | ||
{ | ||
return await BlobRestClient.BlockBlob.PutBlobFromUrlAsync( | ||
clientDiagnostics: ClientDiagnostics, | ||
pipeline: Pipeline, | ||
resourceUri: Uri, | ||
contentLength: 0, | ||
version: Version.ToVersionString(), | ||
copySource: copySource, | ||
timeout: default, | ||
transactionalContentHash: default, | ||
blobContentType: options?.HttpHeaders?.ContentType, | ||
blobContentEncoding: options?.HttpHeaders?.ContentEncoding, | ||
blobContentLanguage: options?.HttpHeaders?.ContentLanguage, | ||
blobContentHash: options?.HttpHeaders?.ContentHash, | ||
blobCacheControl: options?.HttpHeaders?.CacheControl, | ||
// TODO service bug. https://github.com/Azure/azure-sdk-for-net/issues/15969 | ||
// metadata: options?.Metadata, | ||
leaseId: options?.DestinationConditions?.LeaseId, | ||
blobContentDisposition: options?.HttpHeaders?.ContentDisposition, | ||
encryptionKey: CustomerProvidedKey?.EncryptionKey, | ||
encryptionKeySha256: CustomerProvidedKey?.EncryptionKeyHash, | ||
encryptionAlgorithm: CustomerProvidedKey?.EncryptionAlgorithm, | ||
encryptionScope: EncryptionScope, | ||
tier: options?.AccessTier, | ||
ifModifiedSince: options?.DestinationConditions?.IfModifiedSince, | ||
ifUnmodifiedSince: options?.DestinationConditions?.IfUnmodifiedSince, | ||
ifMatch: options?.DestinationConditions?.IfMatch, | ||
ifNoneMatch: options?.DestinationConditions?.IfNoneMatch, | ||
ifTags: options?.DestinationConditions?.TagConditions, | ||
sourceIfModifiedSince: options?.SourceConditions?.IfModifiedSince, | ||
sourceIfUnmodifiedSince: options?.SourceConditions?.IfUnmodifiedSince, | ||
sourceIfMatch: options?.SourceConditions?.IfMatch, | ||
sourceIfNoneMatch: options?.SourceConditions?.IfNoneMatch, | ||
sourceIfTags: options?.SourceConditions?.TagConditions, | ||
requestId: default, | ||
blobTagsString: options?.Tags?.ToTagsString(), | ||
copySourceBlobProperties: options?.CopySourceBlobPropertiesOption == BlobCopySourceBlobPropertiesOption.Overwrite ? false : true, | ||
async: async, | ||
operationName: $"{nameof(BlockBlobClient)}.{nameof(PutBlobFromUrl)}", | ||
cancellationToken: cancellationToken) | ||
.ConfigureAwait(false); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Pipeline.LogException(ex); | ||
throw; | ||
} | ||
finally | ||
{ | ||
Pipeline.LogMethodExit(nameof(BlockBlobClient)); | ||
} | ||
} | ||
} | ||
#endregion PutBlobFromUrl | ||
|
||
#region PartitionedUploader | ||
internal PartitionedUploader<BlobUploadOptions, BlobContentInfo> GetPartitionedUploader( | ||
StorageTransferOptions transferOptions, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. region name is out of date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.