本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Core.MultiBufferMemoryStream.ComputeMD5Hash方法的典型用法代码示例。如果您正苦于以下问题:C# MultiBufferMemoryStream.ComputeMD5Hash方法的具体用法?C# MultiBufferMemoryStream.ComputeMD5Hash怎么用?C# MultiBufferMemoryStream.ComputeMD5Hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Core.MultiBufferMemoryStream
的用法示例。
在下文中一共展示了MultiBufferMemoryStream.ComputeMD5Hash方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutBlockListImpl
/// <summary>
/// Uploads the block list.
/// </summary>
/// <param name="blocks">The blocks to upload.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the blob. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> that uploads the block list.</returns>
internal RESTCommand<NullType> PutBlockListImpl(IEnumerable<PutBlockListItem> blocks, AccessCondition accessCondition, BlobRequestOptions options)
{
MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(this.ServiceClient.BufferManager);
BlobRequest.WriteBlockListBody(blocks, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
#if !WINDOWS_PHONE
string contentMD5 = memoryStream.ComputeMD5Hash();
memoryStream.Seek(0, SeekOrigin.Begin);
#endif
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.Uri);
putCmd.ApplyRequestOptions(options);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => BlobHttpWebRequestFactory.PutBlockList(uri, serverTimeout, this.Properties, accessCondition, ctx);
putCmd.SetHeaders = (r, ctx) =>
{
#if !WINDOWS_PHONE
r.Headers[HttpRequestHeader.ContentMd5] = contentMD5;
#endif
BlobHttpWebRequestFactory.AddMetadata(r, this.Metadata);
};
putCmd.SendStream = memoryStream;
putCmd.RecoveryAction = RecoveryActions.RewindStream;
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex);
CloudBlobSharedImpl.UpdateETagLMTAndSequenceNumber(this.attributes, resp);
this.Properties.Length = -1;
return NullType.Value;
};
return putCmd;
}
示例2: PutBlockListImpl
/// <summary>
/// Uploads the block list.
/// </summary>
/// <param name="blocks">The blocks to upload.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the blob. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand"/> that uploads the block list.</returns>
internal RESTCommand<NullType> PutBlockListImpl(IEnumerable<PutBlockListItem> blocks, AccessCondition accessCondition, BlobRequestOptions options)
{
MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(null /* bufferManager */, (int)(1 * Constants.KB));
BlobRequest.WriteBlockListBody(blocks, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
string contentMD5 = memoryStream.ComputeMD5Hash();
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.Uri);
putCmd.ApplyRequestOptions(options);
putCmd.Handler = this.ServiceClient.AuthenticationHandler;
putCmd.BuildClient = HttpClientFactory.BuildHttpClient;
putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, contentMD5, cmd, ctx);
putCmd.BuildRequest = (cmd, cnt, ctx) =>
{
HttpRequestMessage msg = BlobHttpRequestMessageFactory.PutBlockList(cmd.Uri, cmd.ServerTimeoutInSeconds, this.Properties, accessCondition, cnt, ctx);
BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
};
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex);
CloudBlobSharedImpl.UpdateETagLMTAndSequenceNumber(this.attributes, resp);
this.Properties.Length = -1;
return NullType.Value;
};
return putCmd;
}
示例3: PutBlockListImpl
/// <summary>
/// Uploads the block list.
/// </summary>
/// <param name="blocks">The blocks to upload.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the condition that must be met in order for the request to proceed. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> that uploads the block list.</returns>
internal RESTCommand<NullType> PutBlockListImpl(IEnumerable<PutBlockListItem> blocks, AccessCondition accessCondition, BlobRequestOptions options)
{
MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(this.ServiceClient.BufferManager);
BlobRequest.WriteBlockListBody(blocks, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
#if !WINDOWS_PHONE
string contentMD5 = null;
if (options.UseTransactionalMD5.HasValue && options.UseTransactionalMD5.Value)
{
contentMD5 = memoryStream.ComputeMD5Hash();
memoryStream.Seek(0, SeekOrigin.Begin);
}
#endif
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.attributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.PutBlockList(uri, serverTimeout, this.Properties, accessCondition, useVersionHeader, ctx);
putCmd.SetHeaders = (r, ctx) =>
{
#if !WINDOWS_PHONE
if (contentMD5 != null)
{
r.Headers[HttpRequestHeader.ContentMd5] = contentMD5;
}
#endif
BlobHttpWebRequestFactory.AddMetadata(r, this.Metadata);
};
putCmd.SendStream = memoryStream;
putCmd.StreamToDispose = memoryStream;
putCmd.RecoveryAction = RecoveryActions.RewindStream;
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex);
CloudBlob.UpdateETagLMTLengthAndSequenceNumber(this.attributes, resp, false);
cmd.CurrentResult.IsRequestServerEncrypted = CloudBlob.ParseServerRequestEncrypted(resp);
this.Properties.Length = -1;
return NullType.Value;
};
return putCmd;
}
示例4: PutBlockListImpl
/// <summary>
/// Uploads the block list.
/// </summary>
/// <param name="blocks">The blocks to upload.</param>
/// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the blob. If <c>null</c>, no condition is used.</param>
/// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
/// <returns>A <see cref="RESTCommand"/> that uploads the block list.</returns>
internal RESTCommand<NullType> PutBlockListImpl(IEnumerable<PutBlockListItem> blocks, AccessCondition accessCondition, BlobRequestOptions options)
{
MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(null /* bufferManager */, (int)(1 * Constants.KB));
BlobRequest.WriteBlockListBody(blocks, memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
string contentMD5 = null;
if (options.UseTransactionalMD5.HasValue && options.UseTransactionalMD5.Value)
{
contentMD5 = memoryStream.ComputeMD5Hash();
}
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, this.attributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, contentMD5, cmd, ctx);
putCmd.StreamToDispose = memoryStream;
putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
StorageRequestMessage msg = BlobHttpRequestMessageFactory.PutBlockList(uri, serverTimeout, this.Properties, accessCondition, cnt, ctx, this.ServiceClient.GetCanonicalizer(), this.ServiceClient.Credentials);
BlobHttpRequestMessageFactory.AddMetadata(msg, this.Metadata);
return msg;
};
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, NullType.Value, cmd, ex);
CloudBlob.UpdateETagLMTLengthAndSequenceNumber(this.attributes, resp, false);
cmd.CurrentResult.IsRequestServerEncrypted = CloudBlob.ParseServerRequestEncrypted(resp);
this.Properties.Length = -1;
return NullType.Value;
};
return putCmd;
}