當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudBlob.OpenWrite方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.StorageClient.CloudBlob.OpenWrite方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudBlob.OpenWrite方法的具體用法?C# CloudBlob.OpenWrite怎麽用?C# CloudBlob.OpenWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.StorageClient.CloudBlob的用法示例。


在下文中一共展示了CloudBlob.OpenWrite方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UploadBlobStream

		private static void UploadBlobStream(CloudBlob blob, string sourceFile)
		{
			FileStream fileStream = File.OpenRead(sourceFile);
			using (fileStream)
			{
				byte[] numArray = new byte[0x20000];
				BlobStream blobStream = blob.OpenWrite();
				using (blobStream)
				{
					blobStream.BlockSize = (long)0x20000;
					while (true)
					{
						int num = fileStream.Read(numArray, 0, (int)numArray.Length);
						if (num <= 0)
						{
							break;
						}
						blobStream.Write(numArray, 0, num);
					}
				}
			}
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:22,代碼來源:AzureBlob.cs

示例2: UploadBlobStream

        private static void UploadBlobStream(CloudBlob blob, string sourceFile)
        {
            using (FileStream readStream = File.OpenRead(sourceFile))
            {
                byte[] buffer = new byte[1024 * 128];

                using (BlobStream blobStream = blob.OpenWrite())
                {
                    blobStream.BlockSize = 1024 * 128;

                    while (true)
                    {
                        int bytesCount = readStream.Read(buffer, 0, buffer.Length);

                        if (bytesCount <= 0)
                        {
                            break;
                        }

                        blobStream.Write(buffer, 0, bytesCount);
                    }
                }
            }
        }
開發者ID:modulexcite,項目名稱:CustomActivities,代碼行數:24,代碼來源:UploadPackageToBlobStorage.cs

示例3: WriteWithoutCompression

        static long WriteWithoutCompression(CloudBlob blob, BlobRequestOptions mapped, Action<Stream> writer)
        {
            var md5 = MD5.Create();
            long position;
            using (var stream = blob.OpenWrite(mapped))
            {
                using (var crypto = new CryptoStream(stream, md5, CryptoStreamMode.Write))
                {
                    writer(crypto);
                }

                position = stream.Position;
            }
            blob.Metadata[LokadHashFieldName] = Convert.ToBase64String(md5.Hash);
            blob.SetMetadata();
            return position;
        }
開發者ID:higheredgrowth,項目名稱:lokad-cqrs,代碼行數:17,代碼來源:BlobStorageUtil.cs

示例4: WriteWithCompression

 static long WriteWithCompression(CloudBlob blob, BlobRequestOptions mapped, Action<Stream> writer)
 {
     long position;
     var md5 = MD5.Create();
     blob.Properties.ContentEncoding = "gzip";
     using (var stream = blob.OpenWrite(mapped))
     {
         using (var crypto = new CryptoStream(stream, md5, CryptoStreamMode.Write))
         using (var compress = new GZipStream(crypto, CompressionMode.Compress, true))
         {
             writer(compress);
         }
         position = stream.Position;
     }
     blob.Metadata[LokadHashFieldName] = Convert.ToBase64String(md5.Hash);
     blob.SetMetadata();
     return position;
 }
開發者ID:higheredgrowth,項目名稱:lokad-cqrs,代碼行數:18,代碼來源:BlobStorageUtil.cs

示例5: UploadBlobFile

        public static void UploadBlobFile(byte[] fileBytes, string fileName)
        {
            try
            {
                string storageAccountConnection = string.Empty;

                storageAccountConnection = ConfigurationManager.AppSettings["StorageAccount.ConnectionString"].ToString();

                // If you want to use Windows Azure cloud storage account, use the following
                // code (after uncommenting) instead of the code above.
                cloudStorageAccount = CloudStorageAccount.Parse(storageAccountConnection);

                // Create the blob client, which provides
                // authenticated access to the Blob service.
                blobClient = cloudStorageAccount.CreateCloudBlobClient();

                string deploymentPackageFolderString = string.Empty;

                deploymentPackageFolderString = ConfigurationManager.AppSettings["DeploymentPackageFolder"].ToString();

                // Get the container reference.
                blobContainer = blobClient.GetContainerReference(deploymentPackageFolderString);

                // Create the container if it does not exist.
                blobContainer.CreateIfNotExist();

                // Set permissions on the container.
                containerPermissions = new BlobContainerPermissions();

                // This sample sets the container to have public blobs. Your application
                // needs may be different. See the documentation for BlobContainerPermissions
                // for more information about blob container permissions.
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;

                blobContainer.SetPermissions(containerPermissions);

                blob = blobContainer.GetBlobReference(fileName);

                // Open a stream using the cloud object
                using (BlobStream blobStream = blob.OpenWrite())
                {
                    blobStream.Write(fileBytes, 0, fileBytes.Count());

                    blobStream.Flush();

                    blobStream.Close();
                }
            }
            catch (System.Exception ex)
            {
                Logger.Write(string.Format("Error in UploadBlobFile()  Error: {0}", ex.Message));
            }
        }
開發者ID:yonglehou,項目名稱:Bermuda,代碼行數:53,代碼來源:AzureStorageUtility.cs


注:本文中的Microsoft.WindowsAzure.StorageClient.CloudBlob.OpenWrite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。