/// <summary> /// Implementation of the StartCopyFromBlob method. Result is a BlobAttributes object derived from the response headers. /// </summary> /// <param name="source">The URI of the source blob.</param> /// <param name="sourceAccessCondition">An object that represents the access conditions for the source blob. If null, no condition is used.</param> /// <param name="destAccessCondition">An object that represents the access conditions for the destination blob. If null, no condition is used.</param> /// <param name="options">An object that specifies any additional options for the request.</param> /// <param name="setResult">A delegate for setting the BlobAttributes result.</param> /// <returns>A <see cref="RESTCommand"/> that starts to copy the blob.</returns> internal static RESTCommand <string> StartCopyFromBlobImpl(ICloudBlob blob, BlobAttributes attributes, Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options) { if (sourceAccessCondition != null && !string.IsNullOrEmpty(sourceAccessCondition.LeaseId)) { throw new ArgumentException(SR.LeaseConditionOnSource, "sourceAccessCondition"); } RESTCommand <string> putCmd = new RESTCommand <string>(blob.ServiceClient.Credentials, attributes.Uri); putCmd.ApplyRequestOptions(options); putCmd.Handler = blob.ServiceClient.AuthenticationHandler; putCmd.BuildClient = HttpClientFactory.BuildHttpClient; putCmd.BuildRequest = (cmd, cnt, ctx) => { HttpRequestMessage msg = BlobHttpRequestMessageFactory.CopyFrom(cmd.Uri, cmd.ServerTimeoutInSeconds, source, sourceAccessCondition, destAccessCondition, cnt, ctx); BlobHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata); return(msg); }; putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => { HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex, ctx); CopyState state = BlobHttpResponseParsers.GetCopyAttributes(resp); attributes.Properties = BlobHttpResponseParsers.GetProperties(resp); attributes.Metadata = BlobHttpResponseParsers.GetMetadata(resp); attributes.CopyState = state; return(state.CopyId); }; return(putCmd); }