本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.GetObject方法的具体用法?C# CloudFilesProvider.GetObject怎么用?C# CloudFilesProvider.GetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.GetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDeleteObject
public void TestDeleteObject()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string objectName = Path.GetRandomFileName();
// another random name counts as random content
string fileData = Path.GetRandomFileName();
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
using (MemoryStream uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileData)))
{
provider.CreateObject(containerName, uploadStream, objectName);
}
string actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
provider.DeleteObject(containerName, objectName);
try
{
using (MemoryStream downloadStream = new MemoryStream())
{
provider.GetObject(containerName, objectName, downloadStream);
}
Assert.Fail("Expected an exception (object should not exist)");
}
catch (ResponseException)
{
}
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例2: TestCreateLargeObject
public void TestCreateLargeObject()
{
IObjectStorageProvider provider =
new CloudFilesProvider(Bootstrapper.Settings.TestIdentity)
{
LargeFileBatchThreshold = 81920
};
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string sourceFileName = "DarkKnightRises.jpg";
byte[] content = File.ReadAllBytes("DarkKnightRises.jpg");
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
ProgressMonitor progressMonitor = new ProgressMonitor(content.Length);
provider.CreateObjectFromFile(containerName, sourceFileName, progressUpdated: progressMonitor.Updated);
Assert.IsTrue(progressMonitor.IsComplete, "Failed to notify progress monitor callback of status update.");
using (MemoryStream downloadStream = new MemoryStream())
{
provider.GetObject(containerName, sourceFileName, downloadStream);
Assert.AreEqual(content.Length, GetContainerObjectSize(provider, containerName, sourceFileName));
downloadStream.Position = 0;
byte[] actualData = new byte[downloadStream.Length];
downloadStream.Read(actualData, 0, actualData.Length);
Assert.AreEqual(content.Length, actualData.Length);
using (MD5 md5 = MD5.Create())
{
byte[] contentMd5 = md5.ComputeHash(content);
byte[] actualMd5 = md5.ComputeHash(actualData);
Assert.AreEqual(BitConverter.ToString(contentMd5), BitConverter.ToString(actualMd5));
}
}
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}