本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.BlobAttributes类的典型用法代码示例。如果您正苦于以下问题:C# BlobAttributes类的具体用法?C# BlobAttributes怎么用?C# BlobAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlobAttributes类属于Microsoft.WindowsAzure.Storage.Blob命名空间,在下文中一共展示了BlobAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcquireLeaseImpl
/// <summary>
/// Generates a <see cref="RESTCommand{T}"/> for acquiring a lease.
/// </summary>
/// <param name="leaseTime">A <see cref="TimeSpan"/> representing the span of time for which to acquire the lease,
/// which will be rounded down to seconds. If null, an infinite lease will be acquired. If not null, this must be
/// greater than zero.</param>
/// <param name="proposedLeaseId">A string representing the proposed lease ID for the new lease, or null if no lease ID is proposed.</param>
/// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
/// <param name="options">An object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> implementing the acquire lease operation.</returns>
internal static RESTCommand<string> AcquireLeaseImpl(ICloudBlob blob, BlobAttributes attributes, TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options)
{
int leaseDuration = -1;
if (leaseTime.HasValue)
{
CommonUtils.AssertInBounds("leaseTime", leaseTime.Value, TimeSpan.FromSeconds(1), TimeSpan.MaxValue);
leaseDuration = (int)leaseTime.Value.TotalSeconds;
}
RESTCommand<string> putCmd = new RESTCommand<string>(blob.ServiceClient.Credentials, attributes.Uri);
putCmd.ApplyRequestOptions(options);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => BlobHttpWebRequestFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, ctx);
putCmd.SignRequest = blob.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, null, cmd, ex, ctx);
return BlobHttpResponseParsers.GetLeaseId(resp);
};
return putCmd;
}
示例2: UpdateETagLMTLengthAndSequenceNumber
/// <summary>
/// Retrieve ETag, LMT, Length and Sequence-Number from response.
/// </summary>
/// <param name="blobAttributes">The attributes.</param>
/// <param name="response">The response to parse.</param>
/// <param name="updateLength">If set to <c>true</c>, update the blob length.</param>
internal static void UpdateETagLMTLengthAndSequenceNumber(BlobAttributes blobAttributes, HttpWebResponse response, bool updateLength)
{
BlobProperties parsedProperties = BlobHttpResponseParsers.GetProperties(response);
blobAttributes.Properties.ETag = parsedProperties.ETag ?? blobAttributes.Properties.ETag;
blobAttributes.Properties.LastModified = parsedProperties.LastModified ?? blobAttributes.Properties.LastModified;
blobAttributes.Properties.PageBlobSequenceNumber = parsedProperties.PageBlobSequenceNumber ?? blobAttributes.Properties.PageBlobSequenceNumber;
blobAttributes.Properties.AppendBlobCommittedBlockCount = parsedProperties.AppendBlobCommittedBlockCount ?? blobAttributes.Properties.AppendBlobCommittedBlockCount;
if (updateLength)
{
blobAttributes.Properties.Length = parsedProperties.Length;
}
}
示例3: GetBlobReferenceFromServerImpl
/// <summary>
/// Implements the FetchAttributes method. The attributes are updated immediately.
/// </summary>
/// <param name="blobUri">The URI of the blob.</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 fetches the attributes.</returns>
private RESTCommand<CloudBlob> GetBlobReferenceFromServerImpl(StorageUri blobUri, AccessCondition accessCondition, BlobRequestOptions options)
{
// If the blob Uri contains SAS credentials, we need to use those
// credentials instead of this service client's stored credentials.
StorageCredentials parsedCredentials;
DateTimeOffset? parsedSnapshot;
blobUri = NavigationHelper.ParseBlobQueryAndVerify(blobUri, out parsedCredentials, out parsedSnapshot);
CloudBlobClient client = parsedCredentials != null ? new CloudBlobClient(this.StorageUri, parsedCredentials) : this;
RESTCommand<CloudBlob> getCmd = new RESTCommand<CloudBlob>(client.Credentials, blobUri);
options.ApplyToStorageCommand(getCmd);
getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary;
getCmd.Handler = client.AuthenticationHandler;
getCmd.BuildClient = HttpClientFactory.BuildHttpClient;
getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, parsedSnapshot, accessCondition, cnt, ctx);
getCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex);
BlobAttributes attributes = new BlobAttributes()
{
StorageUri = blobUri,
SnapshotTime = parsedSnapshot,
};
CloudBlob.UpdateAfterFetchAttributes(attributes, resp, false);
switch (attributes.Properties.BlobType)
{
case BlobType.BlockBlob:
return new CloudBlockBlob(attributes, client);
case BlobType.PageBlob:
return new CloudPageBlob(attributes, client);
case BlobType.AppendBlob:
return new CloudAppendBlob(attributes, client);
default:
throw new InvalidOperationException();
}
};
return getCmd;
}
示例4: BreakLeaseImpl
/// <summary>
/// Generates a <see cref="RESTCommand{T}"/> for breaking a lease.
/// </summary>
/// <param name="blobAttributes">The attributes.</param>
/// <param name="breakPeriod">The amount of time to allow the lease to remain, rounded down to seconds.
/// If null, the break period is the remainder of the current lease, or zero for infinite leases.</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}"/> implementing the break lease operation.
/// </returns>
private RESTCommand<TimeSpan> BreakLeaseImpl(BlobAttributes blobAttributes, TimeSpan? breakPeriod, AccessCondition accessCondition, BlobRequestOptions options)
{
int? breakSeconds = null;
if (breakPeriod.HasValue)
{
CommonUtility.AssertInBounds("breakPeriod", breakPeriod.Value, TimeSpan.Zero, TimeSpan.MaxValue);
breakSeconds = (int)breakPeriod.Value.TotalSeconds;
}
RESTCommand<TimeSpan> putCmd = new RESTCommand<TimeSpan>(this.ServiceClient.Credentials, blobAttributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.Lease(uri, serverTimeout, LeaseAction.Break, null /* proposedLeaseId */, null /* leaseDuration */, breakSeconds, accessCondition, useVersionHeader, ctx);
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, TimeSpan.Zero, cmd, ex);
CloudBlob.UpdateETagLMTLengthAndSequenceNumber(blobAttributes, resp, false);
int? remainingLeaseTime = BlobHttpResponseParsers.GetRemainingLeaseTime(resp);
if (!remainingLeaseTime.HasValue)
{
// Unexpected result from service.
throw new StorageException(cmd.CurrentResult, SR.LeaseTimeNotReceived, null /* inner */);
}
return TimeSpan.FromSeconds(remainingLeaseTime.Value);
};
return putCmd;
}
示例5: AbortCopyImpl
/// <summary>
/// Implementation of the AbortCopy method. No result is produced.
/// </summary>
/// <param name="blobAttributes">The attributes.</param>
/// <param name="copyId">The copy ID of the copy operation to abort.</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 aborts the copy.
/// </returns>
private RESTCommand<NullType> AbortCopyImpl(BlobAttributes blobAttributes, string copyId, AccessCondition accessCondition, BlobRequestOptions options)
{
CommonUtility.AssertNotNull("copyId", copyId);
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, blobAttributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, useVersionHeader, ctx);
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.NoContent, resp, NullType.Value, cmd, ex);
return putCmd;
}
示例6: SetPropertiesImpl
/// <summary>
/// Implementation for the SetProperties method.
/// </summary>
/// <param name="blobAttributes">The attributes.</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 sets the properties.
/// </returns>
private RESTCommand<NullType> SetPropertiesImpl(BlobAttributes blobAttributes, AccessCondition accessCondition, BlobRequestOptions options)
{
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, blobAttributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.SetProperties(uri, serverTimeout, blobAttributes.Properties, accessCondition, useVersionHeader, ctx);
putCmd.SetHeaders = (r, ctx) => BlobHttpWebRequestFactory.AddMetadata(r, blobAttributes.Metadata);
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex);
CloudBlob.UpdateETagLMTLengthAndSequenceNumber(blobAttributes, resp, false);
return NullType.Value;
};
return putCmd;
}
示例7: AcquireLeaseImpl
/// <summary>
/// Generates a <see cref="RESTCommand{T}"/> for acquiring a lease.
/// </summary>
/// <param name="blobAttributes">The attributes.</param>
/// <param name="leaseTime">A <see cref="System.TimeSpan"/> representing the span of time for which to acquire the lease,
/// which will be rounded down to seconds. If null, an infinite lease will be acquired. If not null, this must be
/// greater than zero.</param>
/// <param name="proposedLeaseId">A string representing the proposed lease ID for the new lease, or <c>null</c> if no lease ID is proposed.</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}"/> implementing the acquire lease operation.
/// </returns>
private RESTCommand<string> AcquireLeaseImpl(BlobAttributes blobAttributes, TimeSpan? leaseTime, string proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options)
{
int leaseDuration = -1;
if (leaseTime.HasValue)
{
CommonUtility.AssertInBounds("leaseTime", leaseTime.Value, TimeSpan.FromSeconds(1), TimeSpan.MaxValue);
leaseDuration = (int)leaseTime.Value.TotalSeconds;
}
RESTCommand<string> putCmd = new RESTCommand<string>(this.ServiceClient.Credentials, blobAttributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.Lease(uri, serverTimeout, LeaseAction.Acquire, proposedLeaseId, leaseDuration, null /* leaseBreakPeriod */, accessCondition, useVersionHeader, ctx);
putCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Created, resp, null, cmd, ex);
CloudBlob.UpdateETagLMTLengthAndSequenceNumber(blobAttributes, resp, false);
return BlobHttpResponseParsers.GetLeaseId(resp);
};
return putCmd;
}
示例8: ExistsImpl
/// <summary>
/// Implements the Exists method. The attributes are updated immediately.
/// </summary>
/// <param name="blob">The blob object that is calling this method.</param>
/// <param name="attributes">The blob's attributes.</param>
/// <param name="options">An object that specifies additional options for the request.</param>
/// <param name="primaryOnly">If <c>true</c>, the command will be executed against the primary location.</param>
/// <returns>A <see cref="RESTCommand"/> that checks existence.</returns>
internal static RESTCommand<bool> ExistsImpl(ICloudBlob blob, BlobAttributes attributes, BlobRequestOptions options, bool primaryOnly)
{
RESTCommand<bool> getCmd = new RESTCommand<bool>(blob.ServiceClient.Credentials, attributes.StorageUri);
options.ApplyToStorageCommand(getCmd);
getCmd.CommandLocationMode = primaryOnly ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary;
getCmd.Handler = blob.ServiceClient.AuthenticationHandler;
getCmd.BuildClient = HttpClientFactory.BuildHttpClient;
getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, null /* accessCondition */, cnt, ctx);
getCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
if (resp.StatusCode == HttpStatusCode.NotFound)
{
return false;
}
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, true, cmd, ex);
CloudBlobSharedImpl.UpdateAfterFetchAttributes(attributes, resp, false);
return true;
};
return getCmd;
}
示例9: SetPropertiesImpl
/// <summary>
/// Implementation for the SetProperties method.
/// </summary>
/// <param name="blob">The blob object that is calling this method.</param>
/// <param name="attributes">The blob's attributes.</param>
/// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
/// <param name="options">An object that specifies additional options for the request.</param>
/// <returns>A <see cref="RESTCommand"/> that sets the metadata.</returns>
internal static RESTCommand<NullType> SetPropertiesImpl(ICloudBlob blob, BlobAttributes attributes, AccessCondition accessCondition, BlobRequestOptions options)
{
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(blob.ServiceClient.Credentials, attributes.StorageUri);
options.ApplyToStorageCommand(putCmd);
putCmd.Handler = blob.ServiceClient.AuthenticationHandler;
putCmd.BuildClient = HttpClientFactory.BuildHttpClient;
putCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) =>
{
HttpRequestMessage msg = BlobHttpRequestMessageFactory.SetProperties(uri, serverTimeout, attributes.Properties, accessCondition, cnt, ctx);
BlobHttpRequestMessageFactory.AddMetadata(msg, attributes.Metadata);
return msg;
};
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex);
CloudBlobSharedImpl.UpdateETagLMTLengthAndSequenceNumber(attributes, resp, false);
return NullType.Value;
};
return putCmd;
}
示例10: ParseSizeAndLastModified
/// <summary>
/// Retreive ETag and LastModified date time from response.
/// </summary>
/// <param name="response">The response to parse.</param>
internal static void ParseSizeAndLastModified(BlobAttributes attributes, HttpWebResponse response)
{
BlobProperties parsedProperties = BlobHttpResponseParsers.GetProperties(response);
attributes.Properties.ETag = parsedProperties.ETag ?? attributes.Properties.ETag;
attributes.Properties.LastModified = parsedProperties.LastModified ?? attributes.Properties.LastModified;
if (parsedProperties.Length > 0)
{
attributes.Properties.Length = parsedProperties.Length;
}
}
示例11: FetchAttributesImpl
/// <summary>
/// Implements the FetchAttributes method. The attributes are updated immediately.
/// </summary>
/// <param name="blob">The blob object that is calling this method.</param>
/// <param name="attributes">The blob's attributes.</param>
/// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
/// <param name="options">An object that specifies additional options for the request.</param>
/// <returns>A <see cref="RESTCommand"/> that fetches the attributes.</returns>
internal static RESTCommand<NullType> FetchAttributesImpl(ICloudBlob blob, BlobAttributes attributes, AccessCondition accessCondition, BlobRequestOptions options)
{
RESTCommand<NullType> getCmd = new RESTCommand<NullType>(blob.ServiceClient.Credentials, attributes.StorageUri);
options.ApplyToStorageCommand(getCmd);
getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary;
getCmd.Handler = blob.ServiceClient.AuthenticationHandler;
getCmd.BuildClient = HttpClientFactory.BuildHttpClient;
getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => BlobHttpRequestMessageFactory.GetProperties(uri, serverTimeout, attributes.SnapshotTime, accessCondition, cnt, ctx);
getCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex);
CloudBlobSharedImpl.UpdateAfterFetchAttributes(attributes, resp, false);
return NullType.Value;
};
return getCmd;
}
示例12: AbortCopyImpl
/// <summary>
/// Implementation of the AbortCopy method. No result is produced.
/// </summary>
/// <param name="copyId">The copy ID of the copy operation to abort.</param>
/// <param name="accessCondition">An object that represents the access conditions for the operation. If null, no condition is used.</param>
/// <param name="options">An object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> that aborts the copy.</returns>
internal static RESTCommand<NullType> AbortCopyImpl(ICloudBlob blob, BlobAttributes attributes, string copyId, AccessCondition accessCondition, BlobRequestOptions options)
{
CommonUtils.AssertNotNull("copyId", copyId);
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(blob.ServiceClient.Credentials, attributes.Uri);
putCmd.ApplyRequestOptions(options);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => BlobHttpWebRequestFactory.AbortCopy(uri, serverTimeout, copyId, accessCondition, ctx);
putCmd.SignRequest = blob.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(new HttpStatusCode[] { HttpStatusCode.OK, HttpStatusCode.NoContent }, resp, NullType.Value, cmd, ex, ctx);
return putCmd;
}
示例13: GetBlobImpl
/// <summary>
/// Implements getting the stream without specifying a range.
/// </summary>
/// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
/// <param name="options">An object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> that gets the stream.</returns>
internal static RESTCommand<NullType> GetBlobImpl(ICloudBlob blob, BlobAttributes attributes, Stream destStream, long? offset, long? length, AccessCondition accessCondition, BlobRequestOptions options)
{
string lockedETag = null;
AccessCondition lockedAccessCondition = null;
bool isRangeGet = offset.HasValue;
bool arePropertiesPopulated = false;
string storedMD5 = null;
long startingOffset = offset.HasValue ? offset.Value : 0;
long? startingLength = length;
RESTCommand<NullType> getCmd = new RESTCommand<NullType>(blob.ServiceClient.Credentials, attributes.Uri);
getCmd.ApplyRequestOptions(options);
getCmd.RetrieveResponseStream = true;
getCmd.DestinationStream = destStream;
getCmd.CalculateMd5ForResponseStream = !options.DisableContentMD5Validation.Value;
getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) =>
BlobHttpWebRequestFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value, accessCondition, ctx);
getCmd.SignRequest = blob.ServiceClient.AuthenticationHandler.SignRequest;
getCmd.RecoveryAction = (cmd, ex, ctx) =>
{
if ((lockedAccessCondition == null) && !string.IsNullOrEmpty(lockedETag))
{
lockedAccessCondition = AccessCondition.GenerateIfMatchCondition(lockedETag);
if (accessCondition != null)
{
lockedAccessCondition.LeaseId = accessCondition.LeaseId;
}
}
if (cmd.StreamCopyState != null)
{
offset = startingOffset + cmd.StreamCopyState.Length;
if (startingLength.HasValue)
{
length = startingLength.Value - cmd.StreamCopyState.Length;
}
}
getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, context) =>
BlobHttpWebRequestFactory.Get(uri, serverTimeout, attributes.SnapshotTime, offset, length, options.UseTransactionalMD5.Value && !arePropertiesPopulated, lockedAccessCondition ?? accessCondition, context);
};
getCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(offset.HasValue ? HttpStatusCode.PartialContent : HttpStatusCode.OK, resp, NullType.Value, cmd, ex, ctx);
if (!arePropertiesPopulated)
{
CloudBlobSharedImpl.UpdateAfterFetchAttributes(attributes, resp, isRangeGet);
storedMD5 = resp.Headers[HttpResponseHeader.ContentMd5];
if (!options.DisableContentMD5Validation.Value &&
options.UseTransactionalMD5.Value &&
string.IsNullOrEmpty(storedMD5))
{
throw new StorageException(
cmd.CurrentResult,
SR.MD5NotPresentError,
null)
{
IsRetryable = false
};
}
lockedETag = attributes.Properties.ETag;
arePropertiesPopulated = true;
}
return NullType.Value;
};
getCmd.PostProcessResponse = (cmd, resp, ex, ctx) =>
{
long validateLength = startingLength.HasValue ? startingLength.Value : (attributes.Properties.Length - startingOffset);
HttpResponseParsers.ValidateResponseStreamMd5AndLength(validateLength, storedMD5, cmd, cmd.StreamCopyState);
return NullType.Value;
};
return getCmd;
}
示例14: ReleaseLeaseImpl
/// <summary>
/// Generates a <see cref="RESTCommand{T}"/> for releasing a lease.
/// </summary>
/// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
/// <param name="options">An object that specifies any additional options for the request.</param>
/// <returns>A <see cref="RESTCommand{T}"/> implementing the release lease operation.</returns>
internal static RESTCommand<NullType> ReleaseLeaseImpl(ICloudBlob blob, BlobAttributes attributes, AccessCondition accessCondition, BlobRequestOptions options)
{
CommonUtils.AssertNotNull("accessCondition", accessCondition);
if (accessCondition.LeaseId == null)
{
throw new ArgumentException(SR.MissingLeaseIDReleasing, "accessCondition");
}
RESTCommand<NullType> putCmd = new RESTCommand<NullType>(blob.ServiceClient.Credentials, attributes.Uri);
putCmd.ApplyRequestOptions(options);
putCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => BlobHttpWebRequestFactory.Lease(uri, serverTimeout, LeaseAction.Release, null /* proposedLeaseId */, null /* leaseDuration */, null /* leaseBreakPeriod */, accessCondition, ctx);
putCmd.SignRequest = blob.ServiceClient.AuthenticationHandler.SignRequest;
putCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex, ctx);
return putCmd;
}
示例15: FetchAttributesImpl
/// <summary>
/// Implements the FetchAttributes method. The attributes are updated immediately.
/// </summary>
/// <param name="blobAttributes">The attributes.</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 fetches the attributes.
/// </returns>
private RESTCommand<NullType> FetchAttributesImpl(BlobAttributes blobAttributes, AccessCondition accessCondition, BlobRequestOptions options)
{
RESTCommand<NullType> getCmd = new RESTCommand<NullType>(this.ServiceClient.Credentials, blobAttributes.StorageUri);
options.ApplyToStorageCommand(getCmd);
getCmd.CommandLocationMode = CommandLocationMode.PrimaryOrSecondary;
getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, useVersionHeader, ctx) => BlobHttpWebRequestFactory.GetProperties(uri, serverTimeout, blobAttributes.SnapshotTime, accessCondition, useVersionHeader, ctx);
getCmd.SignRequest = this.ServiceClient.AuthenticationHandler.SignRequest;
getCmd.PreProcessResponse = (cmd, resp, ex, ctx) =>
{
HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, NullType.Value, cmd, ex);
CloudBlob.UpdateAfterFetchAttributes(blobAttributes, resp, false);
return NullType.Value;
};
return getCmd;
}