当前位置: 首页>>代码示例>>C#>>正文


C# CloudBlobContainer.GetPermissionsAsync方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.GetPermissionsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.GetPermissionsAsync方法的具体用法?C# CloudBlobContainer.GetPermissionsAsync怎么用?C# CloudBlobContainer.GetPermissionsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer的用法示例。


在下文中一共展示了CloudBlobContainer.GetPermissionsAsync方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetContainerPermissionsAsync

 /// <summary>
 /// Async Get container presssions
 /// </summary>
 /// <param name="container">A cloudblobcontainer object</param>
 /// <param name="accessCondition">Access condition</param>
 /// <param name="options">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <param name="cancellationToken">User cancellation token</param>
 /// <returns>A task object which retrieve the permission of the specified container</returns>
 public Task<BlobContainerPermissions> GetContainerPermissionsAsync(CloudBlobContainer container,
     AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext,
     CancellationToken cancellationToken)
 {
     return container.GetPermissionsAsync(accessCondition, options, operationContext, cancellationToken);
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:15,代码来源:StorageBlobManagement.cs

示例2: SetAnonymousAccessLevelAsync

        /// <summary>
        /// Sets the anonymous access level.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="accessType">Type of the access.</param>
        /// <returns>A Task object.</returns>
        private static async Task SetAnonymousAccessLevelAsync(CloudBlobContainer container, BlobContainerPublicAccessType accessType)
        {
            try
            {
                // Read the existing permissions first so that we have all container permissions. 
                // This ensures that we do not inadvertently remove any shared access policies while setting the public access level.
                BlobContainerPermissions permissions = await container.GetPermissionsAsync();

                // Set the container's public access level.
                permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                await container.SetPermissionsAsync(permissions);

                Console.WriteLine("Container public access set to {0}", accessType.ToString());
                Console.WriteLine();
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }
开发者ID:tamram,项目名称:storage-blob-dotnet-getting-started,代码行数:28,代码来源:Advanced.cs

示例3: CreateSharedAccessPolicyAsync

        /// <summary>
        /// Creates a shared access policy on the container.
        /// </summary>
        /// <param name="container">A CloudBlobContainer object.</param>
        /// <param name="policyName">The name of the stored access policy.</param>
        /// <returns>A Task object.</returns>
        private static async Task CreateSharedAccessPolicyAsync(CloudBlobContainer container, string policyName)
        {
            // Create a new shared access policy and define its constraints.
            // The access policy provides create, write, read, list, and delete permissions.
            SharedAccessBlobPolicy sharedPolicy = new SharedAccessBlobPolicy()
            {
                // When the start time for the SAS is omitted, the start time is assumed to be the time when the storage service receives the request. 
                // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew.
                SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24),
                Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.List |
                    SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Delete
            };

            // Get the container's existing permissions.
            BlobContainerPermissions permissions = await container.GetPermissionsAsync();

            // Add the new policy to the container's permissions, and set the container's permissions.
            permissions.SharedAccessPolicies.Add(policyName, sharedPolicy);
            await container.SetPermissionsAsync(permissions);
        }
开发者ID:tamram,项目名称:storage-blob-dotnet-getting-started,代码行数:26,代码来源:Advanced.cs

示例4: ContainerReadWriteExpectLeaseSuccessAsync

 /// <summary>
 /// Test container reads and writes, expecting success.
 /// </summary>
 /// <param name="testContainer">The container.</param>
 /// <param name="testAccessCondition">The access condition to use.</param>
 private async Task ContainerReadWriteExpectLeaseSuccessAsync(CloudBlobContainer testContainer, AccessCondition testAccessCondition)
 {
     await testContainer.FetchAttributesAsync(testAccessCondition, null /* options */, null);
     await testContainer.GetPermissionsAsync(testAccessCondition, null /* options */, null);
     await testContainer.SetMetadataAsync(testAccessCondition, null /* options */, null);
     await testContainer.SetPermissionsAsync(new BlobContainerPermissions(), testAccessCondition, null /* options */, null);
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:12,代码来源:LeaseTests.cs

示例5: ContainerReadWriteExpectLeaseFailureAsync

        /// <summary>
        /// Test container reads and writes, expecting lease failure.
        /// </summary>
        /// <param name="testContainer">The container.</param>
        /// <param name="testAccessCondition">The failing access condition to use.</param>
        /// <param name="expectedErrorCode">The expected error code.</param>
        /// <param name="description">The reason why these calls should fail.</param>
        private async Task ContainerReadWriteExpectLeaseFailureAsync(CloudBlobContainer testContainer, AccessCondition testAccessCondition, HttpStatusCode expectedStatusCode, string expectedErrorCode, string description)
        {
            OperationContext operationContext = new OperationContext();

            // FetchAttributes is a HEAD request with no extended error info, so it returns with the generic ConditionFailed error code.
            await TestHelper.ExpectedExceptionAsync(
                async () => await testContainer.FetchAttributesAsync(testAccessCondition, null /* options */, operationContext),
                operationContext,
                description + "(Fetch Attributes)",
                HttpStatusCode.PreconditionFailed);

            await TestHelper.ExpectedExceptionAsync(
                async () => await testContainer.GetPermissionsAsync(testAccessCondition, null /* options */, operationContext),
                operationContext,
                description + " (Get Permissions)",
                expectedStatusCode,
                expectedErrorCode);
            await TestHelper.ExpectedExceptionAsync(
                async () => await testContainer.SetMetadataAsync(testAccessCondition, null /* options */, operationContext),
                operationContext,
                description + " (Set Metadata)",
                expectedStatusCode,
                expectedErrorCode);
            await TestHelper.ExpectedExceptionAsync(
                async () => await testContainer.SetPermissionsAsync(new BlobContainerPermissions(), testAccessCondition, null /* options */, operationContext),
                operationContext,
                description + " (Set Permissions)",
                expectedStatusCode,
                expectedErrorCode);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:37,代码来源:LeaseTests.cs

示例6: ContainerReadWriteExpectLeaseSuccessTask

 /// <summary>
 /// Test container reads and writes, expecting success.
 /// </summary>
 /// <param name="testContainer">The container.</param>
 /// <param name="testAccessCondition">The access condition to use.</param>
 private void ContainerReadWriteExpectLeaseSuccessTask(CloudBlobContainer testContainer, AccessCondition testAccessCondition)
 {
     testContainer.FetchAttributesAsync(testAccessCondition, null /* options */, null /* operationContext */).Wait();
     testContainer.GetPermissionsAsync(testAccessCondition, null /* options */, null /* operationContext */).Wait();
     testContainer.SetMetadataAsync(testAccessCondition, null /* options */, null /* operationContext */).Wait();
     testContainer.SetPermissionsAsync(new BlobContainerPermissions(), testAccessCondition, null /* options */, null /* operationContext */).Wait();
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:12,代码来源:LeaseTests.cs

示例7: FormContainerAclResponse

        private async Task<HttpResponseMessage> FormContainerAclResponse(CloudBlobContainer container)
        {
            BlobContainerPermissions permissions = await container.GetPermissionsAsync();
            HttpResponseMessage response = CreateResponse(permissions.SharedAccessPolicies);
            await AddBasicContainerHeaders(response, container);

            //Only add this header if some form of public access is permitted.
            if (permissions.PublicAccess != BlobContainerPublicAccessType.Off)
            {
                response.Headers.Add("x-ms-blob-public-access", permissions.PublicAccess.ToString().ToLower());
            }

            return response;
        }
开发者ID:farukc,项目名称:Dash,代码行数:14,代码来源:ContainerController.cs

示例8: CopyContainer

 static async Task CopyContainer(CloudBlobContainer sourceContainer, CloudBlobContainer destContainer)
 {
     await sourceContainer.FetchAttributesAsync();
     var access = await sourceContainer.GetPermissionsAsync();
     await destContainer.CreateIfNotExistsAsync(access.PublicAccess, null, null);
     await destContainer.SetPermissionsAsync(access);
     destContainer.Metadata.Clear();
     foreach (var metadatum in sourceContainer.Metadata)
     {
         destContainer.Metadata.Add(metadatum);
     }
     await destContainer.SetMetadataAsync();
 }
开发者ID:farukc,项目名称:Dash,代码行数:13,代码来源:AccountManager.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.GetPermissionsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。