當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。