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


C# CloudBlobClient.GetBlobReference方法代码示例

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


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

示例1: DeletePackageFromBlob

		public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
		{
			StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
			string primary = storageKeys.StorageServiceKeys.Primary;
			storageKeys = channel.GetStorageService(subscriptionId, storageName);
			EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
			string str = ((List<string>)endpoints).Find((string p) => p.Contains(".blob."));
			StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(storageName, primary);
			CloudBlobClient cloudBlobClient = new CloudBlobClient(str, storageCredentialsAccountAndKey);
			CloudBlob blobReference = cloudBlobClient.GetBlobReference(packageUri.AbsoluteUri);
			blobReference.DeleteIfExists();
		}
开发者ID:nickchal,项目名称:pash,代码行数:12,代码来源:AzureBlob.cs

示例2: RemoveVHD

		public static void RemoveVHD(IServiceManagement channel, string subscriptionId, Uri mediaLink)
		{
			StorageService storageKeys;
			char[] chrArray = new char[1];
			chrArray[0] = '.';
			string str = mediaLink.Host.Split(chrArray)[0];
			string components = mediaLink.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
			using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)channel))
			{
				storageKeys = channel.GetStorageKeys(subscriptionId, str);
			}
			StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(str, storageKeys.StorageServiceKeys.Primary);
			CloudBlobClient cloudBlobClient = new CloudBlobClient(components, storageCredentialsAccountAndKey);
			CloudBlob blobReference = cloudBlobClient.GetBlobReference(mediaLink.AbsoluteUri);
			blobReference.DeleteIfExists();
		}
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:Disks.cs

示例3: ProcessDynamicRegisterRequest

 private static void ProcessDynamicRegisterRequest(HttpRequest request, HttpResponse response)
 {
     CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
     string blobPath = GetBlobPath(request);
     CloudBlob blob = publicClient.GetBlobReference(blobPath);
     response.Clear();
     try
     {
         string template = blob.DownloadText();
         string returnUrl = request.Params["ReturnUrl"];
         TBRegisterContainer registerContainer = GetRegistrationInfo(returnUrl, request.Url.DnsSafeHost);
         string responseContent = RenderWebSupport.RenderTemplateWithContent(template, registerContainer);
         response.ContentType = blob.Properties.ContentType;
         response.Write(responseContent);
     } catch(StorageClientException scEx)
     {
         response.Write(scEx.ToString());
         response.StatusCode = (int)scEx.StatusCode;
     } finally
     {
         response.End();
     }
 }
开发者ID:abstractiondev,项目名称:TheBallOnAzure,代码行数:23,代码来源:AnonymousBlobStorageHandler.cs

示例4: ProcessAnonymousRequest

 private void ProcessAnonymousRequest(HttpRequest request, HttpResponse response)
 {
     CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
     string blobPath = GetBlobPath(request);
     CloudBlob blob = publicClient.GetBlobReference(blobPath);
     response.Clear();
     try
     {
         blob.FetchAttributes();
         response.ContentType = blob.Properties.ContentType;
         blob.DownloadToStream(response.OutputStream);
     } catch(StorageClientException scEx)
     {
         if (scEx.ErrorCode == StorageErrorCode.BlobNotFound || scEx.ErrorCode == StorageErrorCode.ResourceNotFound || scEx.ErrorCode == StorageErrorCode.BadRequest)
         {
             response.Write("Blob not found or bad request: " + blob.Name + " (original path: " + request.Path + ")");
             response.StatusCode = (int)scEx.StatusCode;
         }
         else
         {
             response.Write("Errorcode: " + scEx.ErrorCode.ToString() + Environment.NewLine);
             response.Write(scEx.ToString());
             response.StatusCode = (int) scEx.StatusCode;
         }
     } finally
     {
         response.End();
     }
 }
开发者ID:abstractiondev,项目名称:TheBallOnAzure,代码行数:29,代码来源:AnonymousBlobStorageHandler.cs

示例5: Translate

        public IEnumerable<CloudBlob> Translate(IExpression expression, CloudBlobClient blobClient, MediaFolder mediaFolder)
        {
            this.Visite(expression);

            if (!string.IsNullOrEmpty(fileName))
            {
                var blob = blobClient.GetBlobReference(mediaFolder.GetMediaFolderItemPath(fileName));
                blob.FetchAttributes();
                return new[] { blob };
            }
            else
            {
                var maxResult = 100;
                if (Take.HasValue)
                {
                    maxResult = Take.Value;
                }
                var take = maxResult;

                var skip = 0;
                if (Skip.HasValue)
                {
                    skip = Skip.Value;
                    maxResult = +skip;
                }
                var blobPrefix = mediaFolder.GetMediaFolderItemPath(prefix);

                if (string.IsNullOrEmpty(prefix))
                {
                    blobPrefix += "/";
                }

                return blobClient.ListBlobsWithPrefixSegmented(blobPrefix, maxResult, null, new BlobRequestOptions() { BlobListingDetails = Microsoft.WindowsAzure.StorageClient.BlobListingDetails.Metadata, UseFlatBlobListing = false })
                    .Results.Skip(skip).Select(it => it as CloudBlob).Take(take);
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:36,代码来源:MediaContentProvider.cs

示例6: CreateStorageCrossDomainPolicy

        private static void CreateStorageCrossDomainPolicy(CloudBlobClient blobClient)
        {
            blobClient.GetContainerReference("$root").CreateIfNotExist();
            blobClient.GetContainerReference("$root").SetPermissions(
                new BlobContainerPermissions()
                {
                    PublicAccess = BlobContainerPublicAccessType.Blob
                });

            var blob = blobClient.GetBlobReference("clientaccesspolicy.xml");
            blob.Properties.ContentType = "text/xml";
            blob.UploadText(@"<?xml version=""1.0"" encoding=""utf-8""?>
            <access-policy>
              <cross-domain-access>
                <policy>
                  <allow-from http-methods=""*"" http-request-headers=""*"">
                    <domain uri=""*"" />
                    <domain uri=""http://*"" />
                  </allow-from>
                  <grant-to>
                    <resource path=""/"" include-subpaths=""true"" />
                  </grant-to>
                </policy>
              </cross-domain-access>
            </access-policy>");
        }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:26,代码来源:FlashCardsService.svc.cs

示例7: CopyDirectoryToBlob

 private void CopyDirectoryToBlob(CloudBlobClient blobClient, string path)
 {
     var files = Directory.EnumerateFiles(path);
     var rootPath = HostingEnvironment.MapPath("~/");
     foreach (var file in files) {
         var container = file.Substring(rootPath.Length, file.Length - rootPath.Length);
         var blobReference = blobClient.GetBlobReference(container);
         try {
             blobReference.FetchAttributes();
         } catch (StorageClientException e) {
             if (e.ErrorCode == StorageErrorCode.ResourceNotFound) {
                 var content = File.ReadAllText(file);
                 blobReference.UploadText(content);
             }
         }
     }
     var directories = Directory.EnumerateDirectories(path);
     foreach (var directory in directories) {
         CopyDirectoryToBlob(blobClient, directory);
     }
 }
开发者ID:ntotten,项目名称:wa-cdnhelpers,代码行数:21,代码来源:CdnHelpersContext.cs

示例8: DownloadJava

		public void DownloadJava(IPaths paths, CloudStorageAccount storageAccount)
		{
			try
			{
				var localJavaZipPath = paths.LocalJavaZip;

				if (File.Exists(localJavaZipPath))
				{
					File.Delete(localJavaZipPath);
					//return;
				}

				Trace.TraceInformation("Downloading Java.");

				var blobClient = new CloudBlobClient(storageAccount.BlobEndpoint, storageAccount.Credentials);

				string blobStoragePath = storageAccount.BlobEndpoint.AbsoluteUri;
				string jBlobRelativePath = RoleEnvironment.GetConfigurationSettingValue(ConfigSettings.JavaBlobNameSetting);

				string javaBlobAddress = blobStoragePath.CombineUris(jBlobRelativePath);

				var blob = blobClient.GetBlobReference(javaBlobAddress);
                
                var option = new BlobRequestOptions();
                option.Timeout = new TimeSpan(0, 15, 0);
				blob.DownloadToFile(localJavaZipPath, option);

				Trace.TraceInformation("Java downloaded.");
			}
			catch (Exception e)
			{
				Trace.Fail(string.Format("Error downloading Java: type <{0}> message <{1}> stack trace <{2}>.", e.GetType().FullName, e.Message, e.StackTrace));
				throw;
			}
		}
开发者ID:jonbgallant,项目名称:Neo4j.Azure.Server,代码行数:35,代码来源:Neo4jManager.cs


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