本文整理汇总了C#中Microsoft.WindowsAzure.Storage.AccessCondition类的典型用法代码示例。如果您正苦于以下问题:C# AccessCondition类的具体用法?C# AccessCondition怎么用?C# AccessCondition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessCondition类属于Microsoft.WindowsAzure.Storage命名空间,在下文中一共展示了AccessCondition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
/// <summary>
/// Constructs a web request to delete the container and all of the blobs within it.
/// </summary>
/// <param name="uri">The absolute URI to the container.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static HttpWebRequest Delete(Uri uri, int? timeout, AccessCondition accessCondition, OperationContext operationContext)
{
UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder();
HttpWebRequest request = HttpWebRequestFactory.Delete(uri, containerBuilder, timeout, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例2: Delete
/// <summary>
/// Constructs a web request to delete the directory and all of the files within it.
/// </summary>
/// <param name="uri">The absolute URI to the directory.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param>
/// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
/// <returns>A <see cref="System.Net.HttpWebRequest"/> object.</returns>
public static HttpWebRequest Delete(Uri uri, int? timeout, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext)
{
UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();
HttpWebRequest request = HttpWebRequestFactory.Delete(uri, directoryBuilder, timeout, useVersionHeader, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例3: GetProperties
/// <summary>
/// Generates a web request to return the properties and user-defined metadata for this directory.
/// </summary>
/// <param name="uri">The absolute URI to the directory.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static HttpRequestMessage GetProperties(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext)
{
UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();
HttpRequestMessage request = HttpRequestMessageFactory.GetProperties(uri, timeout, directoryBuilder, content, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例4: GetMetadata
/// <summary>
/// Generates a web request to return the user-defined metadata for this container.
/// </summary>
/// <param name="uri">The absolute URI to the container.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static StorageRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
{
UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder();
StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, containerBuilder, content, operationContext, canonicalizer, credentials);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例5: ApplyAccessCondition
/// <summary>
/// Applies the condition to the web request.
/// </summary>
/// <param name="request">The request to be modified.</param>
/// <param name="accessCondition">Access condition to be added to the request.</param>
internal static void ApplyAccessCondition(this HttpWebRequest request, AccessCondition accessCondition)
{
if (accessCondition != null)
{
if (!string.IsNullOrEmpty(accessCondition.IfMatchETag))
{
request.Headers[HttpRequestHeader.IfMatch] = accessCondition.IfMatchETag;
}
if (!string.IsNullOrEmpty(accessCondition.IfNoneMatchETag))
{
request.Headers[HttpRequestHeader.IfNoneMatch] = accessCondition.IfNoneMatchETag;
}
if (accessCondition.IfModifiedSinceTime.HasValue)
{
// Not using this property will cause Restricted property exception to be thrown
request.IfModifiedSince = accessCondition.IfModifiedSinceTime.Value.UtcDateTime;
}
if (accessCondition.IfNotModifiedSinceTime.HasValue)
{
request.Headers[HttpRequestHeader.IfUnmodifiedSince] =
HttpUtility.ConvertDateTimeToHttpString(accessCondition.IfNotModifiedSinceTime.Value);
}
if (!string.IsNullOrEmpty(accessCondition.LeaseId))
{
request.Headers[Constants.HeaderConstants.LeaseIdHeader] = accessCondition.LeaseId;
}
}
}
示例6: GetMetadata
/// <summary>
/// Generates a web request to return the user-defined metadata for this container.
/// </summary>
/// <param name="uri">The absolute URI to the container.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static HttpRequestMessage GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext)
{
UriQueryBuilder containerBuilder = GetContainerUriQueryBuilder();
HttpRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, containerBuilder, content, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例7: UploadBlockBlobAsync
public async virtual void UploadBlockBlobAsync(string blobName, Stream streamToUpload, string contentType, AccessCondition accessCondition = null)
{
var blockBlob = GetBlockBlobReference(blobName);
blockBlob.Properties.ContentType = contentType;
await blockBlob.UploadFromStreamAsync(streamToUpload, accessCondition, null, null);
}
示例8: Delete
/// <summary>
/// Constructs a web request to delete the share and all of the files within it.
/// </summary>
/// <param name="uri">The absolute URI to the share.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static HttpRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext)
{
UriQueryBuilder shareBuilder = GetShareUriQueryBuilder();
HttpRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, shareBuilder, content, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例9: GetMetadata
/// <summary>
/// Generates a web request to return the user-defined metadata for this share.
/// </summary>
/// <param name="uri">The absolute URI to the share.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <param name="useVersionHeader">A flag indicating whether to set the x-ms-version HTTP header.</param>
/// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static HttpWebRequest GetMetadata(Uri uri, int? timeout, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext)
{
UriQueryBuilder shareBuilder = GetShareUriQueryBuilder();
HttpWebRequest request = HttpWebRequestFactory.GetMetadata(uri, timeout, shareBuilder, useVersionHeader, operationContext);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例10: UploadTextAsync
static async Task UploadTextAsync(ICloudBlob blob, string text, AccessCondition accessCondition)
{
blob.Properties.ContentEncoding = "UTF-8";
blob.Properties.ContentType = "text/plain";
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text))) {
await blob.UploadFromStreamAsync(stream, accessCondition, null, null);
}
}
示例11: Delete
/// <summary>
/// Constructs a web request to delete the share and all of the files within it.
/// </summary>
/// <param name="uri">The absolute URI to the share.</param>
/// <param name="timeout">The server timeout interval.</param>
/// <param name="accessCondition">The access condition to apply to the request.</param>
/// <returns>A web request to use to perform the operation.</returns>
public static StorageRequestMessage Delete(Uri uri, int? timeout, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
{
UriQueryBuilder shareBuilder = GetShareUriQueryBuilder();
StorageRequestMessage request = HttpRequestMessageFactory.Delete(uri, timeout, shareBuilder, content, operationContext, canonicalizer, credentials);
request.ApplyAccessCondition(accessCondition);
return request;
}
示例12: Run
public static void Run()
{
#region Obtain a client from the connection string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Console.WriteLine("Parsed connection string and created blob client.");
#endregion
#region Obtain reference to images container
CloudBlobContainer imageContainer = blobClient.GetContainerReference("images");
Console.WriteLine("Obtained reference to images container.");
#endregion
#region Show concurrency management using ETag property
Console.WriteLine();
CloudBlockBlob blockBlob1 = imageContainer.GetBlockBlobReference(@"rocks/WhitePocketFocus.jpg");
CloudBlockBlob blockBlob2 = imageContainer.GetBlockBlobReference(@"rocks/WhitePocketFocus.jpg");
blockBlob1.FetchAttributes();
blockBlob2.FetchAttributes();
Console.WriteLine("[1] Obtained ETag {0} for rocks/WhitePocketFocus.jpg in images container.", blockBlob1.Properties.ETag);
Console.WriteLine("[2] Obtained ETag {0} for rocks/WhitePocketFocus.jpg in images container.", blockBlob2.Properties.ETag);
var etag = blockBlob1.Properties.ETag;
var accessCondition = new AccessCondition {IfMatchETag = etag};
var metadata = new Dictionary<string, string>()
{
{ "License", "snowpeak" },
{ "URL", "http://www.flickr.com/photos/snowpeak/7394540572/sizes/l/in/[email protected]/"}
};
Console.WriteLine("[1] Setting metadata on rocks/WhitePocketFocus.jpg in images container.");
foreach (KeyValuePair<string, string> pair in metadata) { blockBlob1.Metadata.Add(pair); }
blockBlob1.SetMetadata(accessCondition);
blockBlob1.FetchAttributes();
Console.WriteLine("[1] New ETag {0} for rocks/WhitePocketFocus.jpg in images container.", blockBlob1.Properties.ETag);
try
{
Console.WriteLine("[2] Setting metadata on rocks/WhitePocketFocus.jpg in images container.");
foreach (KeyValuePair<string, string> pair in metadata) { blockBlob2.Metadata.Add(pair); }
blockBlob2.SetMetadata(accessCondition);
}
catch (Exception exception)
{
Console.WriteLine("[2] Caught exception '" + exception.GetType() + "' while trying to set metadata on rocks/WhitePocketFocus.jpg in images container.");
Console.WriteLine(exception.StackTrace);
}
#endregion
}
示例13: UploadFromStreamEncryptedAsync
public async static Task UploadFromStreamEncryptedAsync(this ICloudBlob blob, IBlobCryptoProvider provider, Stream stream,
AccessCondition accessCondition = null, BlobRequestOptions options = null,
OperationContext operationContext = null)
{
using (Stream encryptedStream = provider.EncryptedStream(stream))
{
await blob.UploadFromStreamAsync(encryptedStream, accessCondition, options, operationContext);
}
}
示例14: UploadText
static void UploadText(ICloudBlob blob, string text, AccessCondition accessCondition)
{
blob.Properties.ContentEncoding = "UTF-8";
blob.Properties.ContentType = "text/plain";
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text)))
{
blob.UploadFromStream(stream, accessCondition);
}
}
示例15: DownloadToFileEncryptedAsync
public async static Task DownloadToFileEncryptedAsync(this ICloudBlob blob, IBlobCryptoProvider provider, string path, FileMode mode,
AccessCondition accessCondition = null, BlobRequestOptions options = null,
OperationContext operationContext = null)
{
using (FileStream fileStream = new FileStream(path, mode))
{
await blob.DownloadToStreamEncryptedAsync(provider, fileStream, accessCondition, options, operationContext);
}
}