• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IStorageBlobManagement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IStorageBlobManagement的典型用法代码示例。如果您正苦于以下问题:C# IStorageBlobManagement类的具体用法?C# IStorageBlobManagement怎么用?C# IStorageBlobManagement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IStorageBlobManagement类属于命名空间,在下文中一共展示了IStorageBlobManagement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateAzureContainerStoredAccessPolicy

        internal string CreateAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName, DateTime? startTime, DateTime? expiryTime, string permission)
        {
            if (!NameUtil.IsValidStoredAccessPolicyName(policyName))
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Resources.InvalidAccessPolicyName, policyName));
            }

            //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //Add new policy
            if (blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ResourceAlreadyExistException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyAlreadyExists, policyName));
            }

            SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
            AccessPolicyHelper.SetupAccessPolicy<SharedAccessBlobPolicy>(policy, startTime, expiryTime, permission);
            blobContainerPermissions.SharedAccessPolicies.Add(policyName, policy);

            //Set permissions back to container
            localChannel.SetContainerPermissions(container, blobContainerPermissions);
            return policyName;
        }
开发者ID:Hamza2404,项目名称:azure-powershell,代码行数:25,代码来源:NewAzureStorageContainerStoredAccessPolicy.cs


示例2: SetContainerAcl

        /// <summary>
        /// set the access level of specified container
        /// </summary>
        /// <param name="name">container name</param>
        /// <param name="accessLevel">access level in ("off", "blob", "container")</param>
        internal async Task SetContainerAcl(long taskId, IStorageBlobManagement localChannel, string name, BlobContainerPublicAccessType accessLevel)
        {
            if (!NameUtil.IsValidContainerName(name))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, name));
            }

            BlobContainerPermissions permissions = new BlobContainerPermissions();
            permissions.PublicAccess = accessLevel;

            BlobRequestOptions requestOptions = RequestOptions;
            AccessCondition accessCondition = null;

            CloudBlobContainer container = localChannel.GetContainerReference(name);

            if (!await localChannel.DoesContainerExistAsync(container, requestOptions, OperationContext, CmdletCancellationToken))
            {
                throw new ResourceNotFoundException(String.Format(Resources.ContainerNotFound, name));
            }

            await localChannel.SetContainerPermissionsAsync(container, permissions, accessCondition, requestOptions, OperationContext, CmdletCancellationToken);

            if (PassThru)
            {
                WriteCloudContainerObject(taskId, localChannel, container, permissions);
            }
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:32,代码来源:SetAzureStorageContainerAcl.cs


示例3: SetDestinationContainer

        public void SetDestinationContainer(IStorageBlobManagement channel, string containerName)
        {
            if (Container == null)
            {
                if (!NameUtil.IsValidContainerName(containerName))
                {
                    throw new ArgumentException(String.Format(Resources.InvalidContainerName, containerName));
                }

                Container = channel.GetContainerReference(containerName);
            }
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:12,代码来源:BlobUploadRequestQueue.cs


示例4: SetAzureContainerStoredAccessPolicy

        internal string SetAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName, DateTime? startTime, DateTime? expiryTime, string permission, bool noStartTime, bool noExpiryTime)
        {
            //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //Set the policy with new value
            if (!blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName));
            }

            SharedAccessBlobPolicy policy = blobContainerPermissions.SharedAccessPolicies[policyName];
            AccessPolicyHelper.SetupAccessPolicy<SharedAccessBlobPolicy>(policy, startTime, expiryTime, permission, noStartTime, noExpiryTime);
            blobContainerPermissions.SharedAccessPolicies[policyName] = policy;

            //Set permission back to container
            localChannel.SetContainerPermissions(container, blobContainerPermissions);
            WriteObject(AccessPolicyHelper.ConstructPolicyOutputPSObject<SharedAccessBlobPolicy>(blobContainerPermissions.SharedAccessPolicies, policyName));
            return policyName;
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:21,代码来源:SetAzureStorageContainerStoredAccessPolicy.cs


示例5: RemoveAzureContainer

        /// <summary>
        /// remove azure container by container name
        /// </summary>
        /// <param name="name">container name</param>
        internal async Task RemoveAzureContainer(long taskId, IStorageBlobManagement localChannel, string name)
        {
            if (!NameUtil.IsValidContainerName(name))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, name));
            }

            BlobRequestOptions requestOptions = RequestOptions;
            AccessCondition accessCondition = null;

            CloudBlobContainer container = localChannel.GetContainerReference(name);

            if (!await localChannel.DoesContainerExistAsync(container, requestOptions, OperationContext, CmdletCancellationToken))
            {
                throw new ResourceNotFoundException(String.Format(Resources.ContainerNotFound, name));
            }

            string result = string.Empty;
            bool removed = false;

            if (force || await OutputStream.ConfirmAsync(name))
            {
                await localChannel.DeleteContainerAsync(container, accessCondition, requestOptions, OperationContext, CmdletCancellationToken);
                result = String.Format(Resources.RemoveContainerSuccessfully, name);
                removed = true;
            }
            else
            {
                result = String.Format(Resources.RemoveContainerCancelled, name);
            }

            OutputStream.WriteVerbose(taskId, result);

            if (PassThru)
            {
                OutputStream.WriteObject(taskId, removed);
            }
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:42,代码来源:RemoveAzureStorageContainer.cs


示例6: CreateAzureContainer

        /// <summary>
        /// create a new azure container
        /// </summary>
        /// <param name="name">container name</param>
        internal async Task CreateAzureContainer(long taskId, IStorageBlobManagement localChannel, string name, BlobContainerPublicAccessType accesslevel)
        {
            if (!NameUtil.IsValidContainerName(name))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, name));
            }

            BlobRequestOptions requestOptions = RequestOptions;
            CloudBlobContainer container = localChannel.GetContainerReference(name);

            BlobContainerPermissions permissions = new BlobContainerPermissions();

            permissions.PublicAccess = accesslevel;

            bool created = await localChannel.CreateContainerIfNotExistsAsync(container, permissions.PublicAccess, requestOptions, OperationContext, CmdletCancellationToken);

            if (!created)
            {
                throw new ResourceAlreadyExistException(String.Format(Resources.ContainerAlreadyExists, name));
            }

            WriteCloudContainerObject(taskId, localChannel, container, permissions);
        }
开发者ID:singhkays,项目名称:azure-powershell,代码行数:27,代码来源:NewAzureStorageContainer.cs


示例7: GetAzureContainerStoredAccessPolicyAsync

        internal async Task GetAzureContainerStoredAccessPolicyAsync(long taskId, IStorageBlobManagement localChannel, string containerName, string policyName)
        {
            SharedAccessBlobPolicies shareAccessPolicies = await GetPoliciesAsync(localChannel, containerName, policyName);

            if (!String.IsNullOrEmpty(policyName))
            {
                if (shareAccessPolicies.Keys.Contains(policyName))
                {
                    OutputStream.WriteObject(taskId, AccessPolicyHelper.ConstructPolicyOutputPSObject<SharedAccessBlobPolicy>(shareAccessPolicies, policyName));
                }
                else
                {
                    throw new ResourceNotFoundException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName));
                }
            }
            else
            {
                foreach (string key in shareAccessPolicies.Keys)
                {
                    OutputStream.WriteObject(taskId, AccessPolicyHelper.ConstructPolicyOutputPSObject<SharedAccessBlobPolicy>(shareAccessPolicies, key));
                }
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:23,代码来源:GetAzureStorageContainerStoredAccessPolicy.cs


示例8: RemoveAzureContainerStoredAccessPolicy

        internal bool RemoveAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName)
        {
            bool success = false;
            string result = string.Empty;
            
             //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //remove the specified policy
            if (!blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ResourceNotFoundException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName));
            }

            if (this.Force || ConfirmRemove(policyName))
            {
                blobContainerPermissions.SharedAccessPolicies.Remove(policyName);
                localChannel.SetContainerPermissions(container, blobContainerPermissions);
                success = true;
            }

            return success;
        }
开发者ID:randorfer,项目名称:azure-powershell,代码行数:24,代码来源:RemoveAzureStorageContainerStoredAccessPolicy.cs


示例9: NewAzureStorageBlobSasTokenCommand

 /// <summary>
 /// Initializes a new instance of the NewAzureStorageBlobSasCommand class.
 /// </summary>
 /// <param name="channel">IStorageBlobManagement channel</param>
 public NewAzureStorageBlobSasTokenCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
     EnableMultiThread = false;
 }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:9,代码来源:NewAzureStorageBlobSasToken.cs


示例10: FakeSetAzureBlobContentCommand

 public FakeSetAzureBlobContentCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
 }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:4,代码来源:SetAzureStorageBlobContentTest.cs


示例11: ListBlobsByPrefix

        /// <summary>
        /// list blobs by blob prefix and container name
        /// </summary>
        /// <param name="containerName">container name</param>
        /// <param name="prefix">blob preifx</param>
        /// <returns>An enumerable collection of IListBlobItem</returns>
        internal async Task ListBlobsByPrefix(long taskId, IStorageBlobManagement localChannel, string containerName, string prefix, Func<CloudBlob, bool> blobFilter = null)
        {
            CloudBlobContainer container = await GetCloudBlobContainerByName(localChannel, containerName);

            BlobRequestOptions requestOptions = RequestOptions;
            bool useFlatBlobListing = true;
            BlobListingDetails details = BlobListingDetails.Snapshots | BlobListingDetails.Metadata | BlobListingDetails.Copy;

            int listCount = InternalMaxCount;
            int MaxListCount = 5000;
            int requestCount = MaxListCount;
            int realListCount = 0;
            BlobContinuationToken continuationToken = ContinuationToken;

            do
            {
                requestCount = Math.Min(listCount, MaxListCount);
                realListCount = 0;
                BlobResultSegment blobResult = await localChannel.ListBlobsSegmentedAsync(container, prefix, useFlatBlobListing,
                    details, requestCount, continuationToken, requestOptions, OperationContext, CmdletCancellationToken);

                foreach (IListBlobItem blobItem in blobResult.Results)
                {
                    CloudBlob blob = blobItem as CloudBlob;

                    if (blob == null)
                    {
                        continue;
                    }

                    if (blobFilter == null || blobFilter(blob))
                    {
                        WriteCloudBlobObject(taskId, localChannel, blob, blobResult.ContinuationToken);
                        realListCount++;
                    }
                }

                if (InternalMaxCount != int.MaxValue)
                {
                    listCount -= realListCount;
                }

                continuationToken = blobResult.ContinuationToken;
            }
            while (listCount > 0 && continuationToken != null);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:52,代码来源:GetAzureStorageBlob.cs


示例12: GetCloudBlobContainerByName

        /// <summary>
        /// get the CloudBlobContainer object by name if container exists
        /// </summary>
        /// <param name="containerName">container name</param>
        /// <returns>return CloudBlobContianer object if specified container exists, otherwise throw an exception</returns>
        internal async Task<CloudBlobContainer> GetCloudBlobContainerByName(IStorageBlobManagement localChannel, string containerName, bool skipCheckExists = false)
        {
            if (!NameUtil.IsValidContainerName(containerName))
            {
                throw new ArgumentException(String.Format(Resources.InvalidContainerName, containerName));
            }

            BlobRequestOptions requestOptions = RequestOptions;
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);

            if (!skipCheckExists && container.ServiceClient.Credentials.IsSharedKey
                && !await localChannel.DoesContainerExistAsync(container, requestOptions, OperationContext, CmdletCancellationToken))
            {
                throw new ArgumentException(String.Format(Resources.ContainerNotFound, containerName));
            }

            return container;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:23,代码来源:GetAzureStorageBlob.cs


示例13: StartCopyAsync

        /// <summary>
        /// Start copy using transfer mangager by source uri
        /// </summary>
        /// <param name="uri">source uri</param>
        /// <param name="destContainer">Destination CloudBlobContainer object</param>
        /// <param name="destBlobName">Destination blob name</param>
        /// <returns>Destination CloudBlob object</returns>
        private async Task StartCopyAsync(long taskId, IStorageBlobManagement destChannel, Uri uri, CloudBlobContainer destContainer, string destBlobName)
        {
            NameUtil.ValidateContainerName(destContainer.Name);
            NameUtil.ValidateBlobName(destBlobName);

            await this.StartCopyFromUri(taskId, destChannel, uri, destContainer.GetBlockBlobReference(destBlobName));
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:14,代码来源:StartAzureStorageBlobCopy.cs


示例14: GetDestBlob

        private CloudBlob GetDestBlob(IStorageBlobManagement destChannel, string destContainerName, string destBlobName, BlobType blobType)
        {
            NameUtil.ValidateContainerName(destContainerName);
            NameUtil.ValidateBlobName(destBlobName);

            CloudBlobContainer container = destChannel.GetContainerReference(destContainerName);
            CloudBlob destBlob = null;
            if (BlobType.PageBlob == blobType)
            {
                destBlob = container.GetPageBlobReference(destBlobName);
            }
            else if (BlobType.BlockBlob == blobType)
            {
                destBlob = container.GetBlockBlobReference(destBlobName);
            }
            else if (BlobType.AppendBlob == blobType)
            {
                destBlob = container.GetAppendBlobReference(destBlobName);
            }
            else
            {
                throw new ArgumentException(String.Format(Resources.InvalidBlobType, blobType, destBlobName));
            }

            return destBlob;
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:26,代码来源:StartAzureStorageBlobCopy.cs


示例15: GetDestinationBlobWithCopyId

 /// <summary>
 /// Get DestinationBlob with specified copy id
 /// </summary>
 /// <param name="container">CloudBlobContainer object</param>
 /// <param name="blobName">Blob name</param>
 /// <param name="copyId">Current CopyId</param>
 /// <returns>Destination ICloudBlob object</returns>
 private ICloudBlob GetDestinationBlobWithCopyId(IStorageBlobManagement destChannel, CloudBlobContainer container, string blobName)
 {
     AccessCondition accessCondition = null;
     BlobRequestOptions options = RequestOptions;
     ICloudBlob blob = destChannel.GetBlobReferenceFromServer(container, blobName, accessCondition, options, OperationContext);
     return blob;
 }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:14,代码来源:StartAzureStorageBlobCopy.cs


示例16: GetAzureStorageBlobContentCommand

 /// <summary>
 /// Initializes a new instance of the GetAzureStorageBlobContentCommand class.
 /// </summary>
 /// <param name="channel">IStorageBlobManagement channel</param>
 public GetAzureStorageBlobContentCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
     fileNameResolver = new AzureToFileSystemFileNameResolver(() => NameUtil.WindowsMaxFileNameLength);
 }
开发者ID:AzureRT,项目名称:azure-sdk-tools,代码行数:9,代码来源:GetAzureStorageBlobContent.cs


示例17: NewAzureStorageBlobSasTokenCommand

 /// <summary>
 /// Initializes a new instance of the NewAzureStorageBlobSasCommand class.
 /// </summary>
 /// <param name="channel">IStorageBlobManagement channel</param>
 public NewAzureStorageBlobSasTokenCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
 }
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:8,代码来源:NewAzureStorageBlobSasToken.cs


示例18: GetAzureStorageBlobCommand

 /// <summary>
 /// Initializes a new instance of the GetAzureStorageBlobCommand class.
 /// </summary>
 /// <param name="channel">IStorageBlobManagement channel</param>
 public GetAzureStorageBlobCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:8,代码来源:GetAzureStorageBlob.cs


示例19: RemoveStorageAzureBlobCommand

 /// <summary>
 /// Initializes a new instance of the RemoveStorageAzureBlobCommand class.
 /// </summary>
 /// <param name="channel">IStorageBlobManagement channel</param>
 public RemoveStorageAzureBlobCommand(IStorageBlobManagement channel)
 {
     Channel = channel;
 }
开发者ID:shanmukrao,项目名称:azure-sdk-tools,代码行数:8,代码来源:RemoveAzureStorageBlob.cs


示例20: ListBlobsByName

        /// <summary>
        /// list blobs by blob name and container name
        /// </summary>
        /// <param name="containerName">container name</param>
        /// <param name="blobName">blob name pattern</param>
        /// <returns>An enumerable collection of IListBlobItem</returns>
        internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localChannel, string containerName, string blobName)
        {
            CloudBlobContainer container = null;
            BlobRequestOptions requestOptions = RequestOptions;
            AccessCondition accessCondition = null;

            string prefix = string.Empty;

            if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName))
            {
                container = await GetCloudBlobContainerByName(localChannel, containerName);
                prefix = NameUtil.GetNonWildcardPrefix(blobName);
                WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
                WildcardPattern wildcard = null;

                if (!String.IsNullOrEmpty(blobName))
                {
                    wildcard = new WildcardPattern(blobName, options);
                }

                Func<CloudBlob, bool> blobFilter = (blob) => wildcard == null || wildcard.IsMatch(blob.Name);
                await ListBlobsByPrefix(taskId, localChannel, containerName, prefix, blobFilter);
            }
            else
            {
                container = await GetCloudBlobContainerByName(localChannel, containerName, true);

                if (!NameUtil.IsValidBlobName(blobName))
                {
                    throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName));
                }

                CloudBlob blob = await localChannel.GetBlobReferenceFromServerAsync(container, blobName, accessCondition, requestOptions, OperationContext, CmdletCancellationToken);

                if (null == blob)
                {
                    throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName));
                }
                else
                {
                    WriteCloudBlobObject(taskId, localChannel, blob);
                }
            }
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:50,代码来源:GetAzureStorageBlob.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IStorageFile类代码示例发布时间:2022-05-24
下一篇:
C# IStorageActionsAccessor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap