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


C# IStorageBlobManagement.GetBlobReferenceFromServerAsync方法代码示例

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


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

示例1: 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

示例2: RemoveAzureBlob

        /// <summary>
        /// remove azure blob
        /// </summary>
        /// <param name="container">CloudBlobContainer object</param>
        /// <param name="blobName">blob name</param>
        /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns>
        internal async Task RemoveAzureBlob(long taskId, IStorageBlobManagement localChannel, CloudBlobContainer container, string blobName)
        {
            if (!NameUtil.IsValidBlobName(blobName))
            {
                throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName));
            }

            ValidatePipelineCloudBlobContainer(container);
            AccessCondition accessCondition = null;
            BlobRequestOptions requestOptions = null;

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

            if (null == blob && container.ServiceClient.Credentials.IsSharedKey)
            {
                throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name));
            }
            else
            {
                //Construct the blob as CloudBlockBlob no matter what's the real blob type
                //We can't get the blob type if Credentials only have the delete permission and don't have read permission.
                blob = container.GetBlockBlobReference(blobName);
            }

            await RemoveAzureBlob(taskId, localChannel, blob, true);
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:33,代码来源:RemoveAzureStorageBlob.cs


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