本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.GetObjectHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.GetObjectHeaders方法的具体用法?C# CloudFilesProvider.GetObjectHeaders怎么用?C# CloudFilesProvider.GetObjectHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.GetObjectHeaders方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Throw_Exception_When_Calling_Get_Headers_For_Object_And_Object_Name_Is_Empty
public void Should_Throw_Exception_When_Calling_Get_Headers_For_Object_And_Object_Name_Is_Empty()
{
string objectNameLocal = string.Empty;
var provider = new CloudFilesProvider();
var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectNameLocal, identity: _testIdentity);
Assert.Fail("Expected exception was not thrown.");
}
示例2: Should_Create_Object_From_File_With_Headers
public void Should_Create_Object_From_File_With_Headers()
{
string filePath = Path.Combine(Directory.GetCurrentDirectory(), objectName);
string fileName = Path.GetFileName(filePath);
Stream stream = System.IO.File.OpenRead(filePath);
var etag = GetMD5Hash(filePath);
stream.Position = 0;
var headers = new Dictionary<string, string>();
headers.Add("ETag", etag);
int cnt = 0;
var info = new FileInfo(filePath);
var totalBytest = info.Length;
var provider = new CloudFilesProvider(_testIdentity);
provider.CreateObjectFromFile(containerName, filePath, fileName, 65536, headers, null, (bytesWritten) =>
{
cnt = cnt + 1;
if (cnt % 10 != 0)
return;
var x = (float)bytesWritten / (float)totalBytest;
var percentCompleted = (float)x * 100.00;
Console.WriteLine(string.Format("{0:0.00} % Completed (Writen: {1} of {2})", percentCompleted, bytesWritten, totalBytest));
});
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.AreEqual(fileName, containerGetObjectsResponse.Where(x => x.Name.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Name);
var objectHeadersResponse = provider.GetObjectHeaders(containerName, fileName, identity: _testIdentity);
Assert.IsNotNull(objectHeadersResponse);
Assert.AreEqual(etag, objectHeadersResponse.Where(x => x.Key.Equals("ETag", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);
}
示例3: Should_Copy_Object_When_Not_Passing_Content_Length_And_Passing_Expiring_Header
public void Should_Copy_Object_When_Not_Passing_Content_Length_And_Passing_Expiring_Header()
{
// Object will expire 2 days from now.
var epoch = (int)(DateTime.UtcNow.AddDays(2) - new DateTime(1970, 1, 1)).TotalSeconds;
var header = new Dictionary<string, string> { { CloudFilesProvider.ObjectDeleteAt, epoch.ToString() } };
var provider = new CloudFilesProvider(_testIdentity);
var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, header);
Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
var sourceheader = provider.GetObjectHeaders(sourceContainerName, sourceObjectName);
var destinationHeader = provider.GetObjectHeaders(destinationContainerName, destinationObjectName);
Assert.AreEqual(sourceheader.First(h => h.Key.Equals("ETag", StringComparison.OrdinalIgnoreCase)).Value, destinationHeader.First(h => h.Key.Equals("ETag", StringComparison.OrdinalIgnoreCase)).Value);
Assert.AreEqual(sourceheader.First(h => h.Key.Equals("Content-Length", StringComparison.OrdinalIgnoreCase)).Value, destinationHeader.First(h => h.Key.Equals("Content-Length", StringComparison.OrdinalIgnoreCase)).Value);
}
示例4: Should_Get_Headers_For_Object
public void Should_Get_Headers_For_Object()
{
var provider = new CloudFilesProvider();
var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectName, identity: _testIdentity);
Assert.IsNotNull(objectHeadersResponse);
//Assert.AreEqual("Christian Bale", objectHeadersResponse.Where(x => x.Key.Equals("X-Object-Meta-Actor", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);
}
示例5: Should_Copy_Object_When_Passing_Content_Length
public void Should_Copy_Object_When_Passing_Content_Length()
{
var provider = new CloudFilesProvider(_testIdentity);
var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName);
Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
var sourceheader = provider.GetObjectHeaders(sourceContainerName, sourceObjectName);
var destinationHeader = provider.GetObjectHeaders(destinationContainerName, destinationObjectName);
Assert.AreEqual(sourceheader.First(h => h.Key.Equals("ETag", StringComparison.OrdinalIgnoreCase)).Value, destinationHeader.First(h => h.Key.Equals("ETag", StringComparison.OrdinalIgnoreCase)).Value);
Assert.AreEqual(sourceheader.First(h => h.Key.Equals("Content-Length", StringComparison.OrdinalIgnoreCase)).Value, destinationHeader.First(h => h.Key.Equals("Content-Length", StringComparison.OrdinalIgnoreCase)).Value);
}
示例6: TestGetObjectHeaders
public void TestGetObjectHeaders()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string objectName = Path.GetRandomFileName();
string objectData = "";
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(objectData));
provider.CreateObject(containerName, stream, objectName);
Dictionary<string, string> headers = provider.GetObjectHeaders(containerName, objectName);
Assert.IsNotNull(headers);
Console.WriteLine("Headers");
foreach (var pair in headers)
{
Assert.IsFalse(string.IsNullOrEmpty(pair.Key));
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
}
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例7: Should_Create_Object_From_File_With_Headers
public void Should_Create_Object_From_File_With_Headers()
{
string filePath = Path.Combine(Directory.GetCurrentDirectory(), objectName);
var etag = GetMD5Hash(filePath);
var headers = new Dictionary<string, string> {{"ETag", etag}};
var provider = new CloudFilesProvider(_testIdentity);
provider.CreateObjectFromFile(containerName, filePath, objectName, headers: headers);
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.AreEqual(objectName, containerGetObjectsResponse.Where(x => x.Name.Equals(objectName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Name);
var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectName, identity: _testIdentity);
Assert.IsNotNull(objectHeadersResponse);
Assert.AreEqual(etag, objectHeadersResponse.Where(x => x.Key.Equals("ETag", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);
}
示例8: Should_Create_Object_From_Stream_With_Headers
public void Should_Create_Object_From_Stream_With_Headers()
{
var etag = GetMD5Hash(objectName);
var headers = new Dictionary<string, string> {{"ETag", etag}};
var provider = new CloudFilesProvider(_testIdentity);
using (var stream = File.OpenRead(objectName))
{
provider.CreateObject(containerName, stream, objectName, headers: headers);
}
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.AreEqual(objectName, containerGetObjectsResponse.Where(x => x.Name.Equals(objectName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Name);
var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectName, identity: _testIdentity);
Assert.IsNotNull(objectHeadersResponse);
Assert.AreEqual(etag, objectHeadersResponse.Where(x => x.Key.Equals("ETag", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);
}