本文整理匯總了C#中Agent.SetAzureStorageBlobContent方法的典型用法代碼示例。如果您正苦於以下問題:C# Agent.SetAzureStorageBlobContent方法的具體用法?C# Agent.SetAzureStorageBlobContent怎麽用?C# Agent.SetAzureStorageBlobContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Agent
的用法示例。
在下文中一共展示了Agent.SetAzureStorageBlobContent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UploadBlobTest
/// <summary>
/// Parameters:
/// Block:
/// True for BlockBlob, false for PageBlob
/// </summary>
internal void UploadBlobTest(Agent agent, string UploadFilePath, Microsoft.WindowsAzure.Storage.Blob.BlobType Type)
{
string NEW_CONTAINER_NAME = Utility.GenNameString("upload-");
string blobName = Path.GetFileName(UploadFilePath);
Collection<Dictionary<string, object>> comp = new Collection<Dictionary<string, object>>();
Dictionary<string, object> dic = Utility.GenComparisonData(StorageObjectType.Blob, blobName);
dic["BlobType"] = Type;
comp.Add(dic);
// create the container
CloudBlobContainer container = CommonStorageAccount.CreateCloudBlobClient().GetContainerReference(NEW_CONTAINER_NAME);
container.CreateIfNotExists();
try
{
//--------------Upload operation--------------
Test.Assert(agent.SetAzureStorageBlobContent(UploadFilePath, NEW_CONTAINER_NAME, Type), Utility.GenComparisonData("SendAzureStorageBlob", true));
ICloudBlob blob = CommonBlobHelper.QueryBlob(NEW_CONTAINER_NAME, blobName);
CloudBlobUtil.PackBlobCompareData(blob, dic);
// Verification for returned values
agent.OutputValidation(comp);
Test.Assert(blob != null && blob.Exists(), "blob " + blobName + " should exist!");
}
finally
{
// cleanup
container.DeleteIfExists();
}
}
示例2: UploadBlobTestGB
internal void UploadBlobTestGB(Agent agent, StorageBlob.BlobType blobType)
{
string uploadFilePath = @".\" + Utility.GenNameString("gbupload");
string containerName = Utility.GenNameString("gbupload-");
string blobName = Path.GetFileName(uploadFilePath);
// create the container
StorageBlob.CloudBlobContainer container = blobUtil.CreateContainer(containerName);
// Generate a 512 bytes file which contains GB18030 characters
File.WriteAllText(uploadFilePath, GB18030String);
try
{
//--------------Upload operation--------------
Test.Assert(agent.SetAzureStorageBlobContent(uploadFilePath, containerName, blobType),
Utility.GenComparisonData("SendAzureStorageBlob", true));
StorageBlob.ICloudBlob blob = CloudBlobUtil.GetBlob(container, blobName, blobType);
Test.Assert(blob != null && blob.Exists(), "blob " + blobName + " should exist!");
// Check MD5
string localMd5 = Helper.GetFileContentMD5(uploadFilePath);
blob.FetchAttributes();
Test.Assert(localMd5 == blob.Properties.ContentMD5,
string.Format("blob content md5 should be {0}, and actualy it's {1}", localMd5, blob.Properties.ContentMD5));
}
finally
{
// cleanup
container.DeleteIfExists();
File.Delete(uploadFilePath);
}
}