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


C# CloudBlobContainer.GetPermissions方法代码示例

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


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

示例1: HomeController

        public HomeController()
        {
            storageAccount = CloudStorageAccount.Parse(
            ConfigurationManager.AppSettings["StorageConnectionString"]);

            tableClient = storageAccount.CreateCloudTableClient();

            table = tableClient.GetTableReference("fouramigos");

            table.CreateIfNotExists();

            blobClient = storageAccount.CreateCloudBlobClient();

            container = blobClient.GetContainerReference("fouramigos");

            container.CreateIfNotExists();

            BlobContainerPermissions permissions = container.GetPermissions();
            permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            container.SetPermissions(permissions);


            //lägga till nya
            //var tablemodels = new TableModel("Brutus", "Uggla") { Location = "T4", Description="Uggla i träd", Type="Foto" };
            //var tablemodels1 = new TableModel("brutus", "Örn") { Location = "T4", Description="Örn som flyger", Type = "Foto" };

            //var opreation = TableOperation.Insert(tablemodels);
            //var operation2 = TableOperation.Insert(tablemodels1);

            //table.Execute(opreation);
            //table.Execute(operation2);
        }
开发者ID:Quintoh,项目名称:Konstprojektet,代码行数:32,代码来源:HomeController.cs

示例2: BlobStorageAsync

		/// <summary>
		/// Creates a new BlobStorage object
		/// </summary>
		/// <param name="blobContainerName">The name of the blob to be managed</param>
		/// <param name="storageConnectionString">The connection string pointing to the storage account (this can be local or hosted in Windows Azure</param>
		public BlobStorageAsync(string blobContainerName, string storageConnectionString)
		{
			Validate.BlobContainerName(blobContainerName, "blobContainerName");
			Validate.String(storageConnectionString, "storageConnectionString");

			var cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString);
			var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();

			cloudBlobContainer = cloudBlobClient.GetContainerReference(blobContainerName);
			cloudBlobContainer.CreateIfNotExists();

			var permissions = cloudBlobContainer.GetPermissions();
			permissions.PublicAccess = BlobContainerPublicAccessType.Container;
			cloudBlobContainer.SetPermissions(permissions);
		}
开发者ID:cmatskas,项目名称:Azure.Storage,代码行数:20,代码来源:BlobStorageAsync.cs

示例3: CreateSharedAccessPolicy

        /// <summary>
        /// Creates a new Shared Access Policy for the container
        /// </summary>
        /// <param name="blobClient">The blob client to use for this operation</param>
        /// <param name="container">The container to create the policy for</param>
        /// <param name="policyName">The name of the policy</param>
        static void CreateSharedAccessPolicy(CloudBlobClient blobClient, CloudBlobContainer container,
    string policyName)
        {
            //Create a new shared access policy and define its constraints.
            SharedAccessBlobPolicy sharedPolicy = new SharedAccessBlobPolicy()
            {
                // What is the expiration date of this policy?
                SharedAccessExpiryTime = DateTime.UtcNow.AddYears(1),
                // What permissions does this policy grant?
                Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.List
            };

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

            //Add the new policy to the container's permissions, and set the container's permissions.
            permissions.SharedAccessPolicies.Add(policyName, sharedPolicy);
            container.SetPermissions(permissions);
        }
开发者ID:Azure-Samples,项目名称:hdinsight-dotnet-python-azure-storage-shared-access-signature,代码行数:25,代码来源:Program.cs

示例4: AzureContext

        //Initializing constructor...
        public AzureContext(string appSettingsKey) 
        {
            if ( null == _cloudStorageAccount ) //ASSUMPTION: This member is ALWAYS allocated first...
            {
                lock (lockObject)
                {
                    if ( null == _cloudStorageAccount )
                    {
                        string connectionString = ConfigurationManager.AppSettings[appSettingsKey];
                        _cloudStorageAccount = CloudStorageAccount.Parse(connectionString);

                        _cloudBlobClient = _cloudStorageAccount.CreateCloudBlobClient();

                        _cloudBlobContainer = _cloudBlobClient.GetContainerReference(ConfigurationManager.AppSettings["blobContainer"]);

                        //ASSUMPTION: container access settings: public read access blobs only...
                        BlobContainerPermissions bcp = _cloudBlobContainer.GetPermissions();

                        Debug.Assert(BlobContainerPublicAccessType.Blob == bcp.PublicAccess);
                    }
                }
            }
        }
开发者ID:CUAHSI,项目名称:HydroClient,代码行数:24,代码来源:AzureContext.cs

示例5: GetContainerPermissions

 /// <summary>
 /// 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>
 /// <returns>The container's permission</returns>
 public BlobContainerPermissions GetContainerPermissions(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     return container.GetPermissions(accessCondition, options, operationContext);
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:12,代码来源:StorageBlobManagement.cs

示例6: GetNonExpiredContainerPolicy

        private SharedAccessBlobPolicy GetNonExpiredContainerPolicy(CloudBlobContainer container)
        {
            SharedAccessBlobPolicy policy;
            bool policyExpired = false;
            var permissions = container.GetPermissions();
            var policyExists = permissions.SharedAccessPolicies.TryGetValue(PolicyName, out policy);

            if (policyExists)
            {
                policyExpired = policy.SharedAccessExpiryTime < DateTime.UtcNow;
            }

            if (policyExpired || !policyExists)
            {
                policy = CreateSharedAccessPolicy();
                permissions.SharedAccessPolicies.Remove(PolicyName);
                permissions.SharedAccessPolicies.Add(PolicyName, policy);
                container.SetPermissions(permissions);
            }

            return policy;
        }
开发者ID:NewforceComputerTechnologies,项目名称:MicrosoftAzureTrainingKit,代码行数:22,代码来源:VideoStorage.cs

示例7: PackContainerCompareData

 public static void PackContainerCompareData(CloudBlobContainer container, Dictionary<string, object> dic)
 {
     BlobContainerPermissions permissions = container.GetPermissions();
     dic["PublicAccess"] = permissions.PublicAccess;
     dic["Permission"] = permissions;
     dic["LastModified"] = container.Properties.LastModified;
 }
开发者ID:Viachaslau,项目名称:azure-sdk-tools,代码行数:7,代码来源:CloudBlobUtil.cs

示例8: ContainerReadWriteExpectLeaseSuccess

 /// <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 ContainerReadWriteExpectLeaseSuccess(CloudBlobContainer testContainer, AccessCondition testAccessCondition)
 {
     testContainer.FetchAttributes(testAccessCondition, null /* options */);
     testContainer.GetPermissions(testAccessCondition, null /* options */);
     testContainer.SetMetadata(testAccessCondition, null /* options */);
     testContainer.SetPermissions(new BlobContainerPermissions(), testAccessCondition, null /* options */);
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:12,代码来源:LeaseTests.cs

示例9: ContainerReadWriteExpectLeaseFailure

        /// <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 void ContainerReadWriteExpectLeaseFailure(CloudBlobContainer testContainer, AccessCondition testAccessCondition, HttpStatusCode expectedStatusCode, string expectedErrorCode, string description)
        {
            // FetchAttributes is a HEAD request with no extended error info, so it returns with the generic ConditionFailed error code.
            TestHelper.ExpectedException(
                () => testContainer.FetchAttributes(testAccessCondition, null /* options */),
                description + "(Fetch Attributes)",
                HttpStatusCode.PreconditionFailed);

            TestHelper.ExpectedException(
                () => testContainer.GetPermissions(testAccessCondition, null /* options */),
                description + " (Get Permissions)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => testContainer.SetMetadata(testAccessCondition, null /* options */),
                description + " (Set Metadata)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => testContainer.SetPermissions(new BlobContainerPermissions(), testAccessCondition, null /* options */),
                description + " (Set Permissions)",
                expectedStatusCode,
                expectedErrorCode);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:31,代码来源:LeaseTests.cs

示例10: CreateSharedAccessPolicy

        static void CreateSharedAccessPolicy(CloudBlobClient blobClient, CloudBlobContainer container, string policyName)
        {
            SharedAccessBlobPolicy sharedPolicy = new SharedAccessBlobPolicy()
            {
                SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24),
                                            Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read
            };

            BlobContainerPermissions permissions = container.GetPermissions();

            permissions.SharedAccessPolicies.Add(policyName, sharedPolicy);
            container.SetPermissions(permissions);


        }
开发者ID:faiyaz-shaik,项目名称:Prototypes,代码行数:15,代码来源:Program.cs

示例11: GetContainer

        public CloudBlobContainer GetContainer(string containerName)
        {
            container = blobClient.GetContainerReference(containerName);

            if (container.CreateIfNotExists())
            {
                // configure container for public access
                var permissions = container.GetPermissions();
                permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                container.SetPermissions(permissions);
            }

            return container;
        }
开发者ID:cberio,项目名称:thisistracer,代码行数:14,代码来源:PhotoMapRepository.cs


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