本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.ListObjects方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.ListObjects方法的具体用法?C# CloudFilesProvider.ListObjects怎么用?C# CloudFilesProvider.ListObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.ListObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CFProviderListContainerObjects
protected void CFProviderListContainerObjects(string cfcontainername, string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
var Cfobjects = CloudFilesProvider.ListObjects(cfcontainername, null, null, null, dcregion, dcsnet);
CFContainerContentsDDL.DataSource = Cfobjects;
CFContainerContentsDDL.DataTextField = "Name";
CFContainerContentsDDL.DataBind();
}
示例2: ListContainer
private IEnumerable<ContainerObject> ListContainer(CloudIdentity cloudIdentity, string container, int? limit = null, string prefix = null, string region = null, bool useInternalUrl = false) {
var provider = new CloudFilesProvider(cloudIdentity);
ContainerObject lastContainerObject = null;
do {
string marker = lastContainerObject != null ? lastContainerObject.Name : null;
IEnumerable<ContainerObject> containerObjects = provider.ListObjects(container, limit, marker, null, prefix, region, useInternalUrl, cloudIdentity);
lastContainerObject = null;
foreach (ContainerObject containerObject in containerObjects) {
lastContainerObject = containerObject;
yield return containerObject;
}
} while (lastContainerObject != null);
}
示例3: DownloadFromRackSpaceCloudFiles
public bool DownloadFromRackSpaceCloudFiles()
{
bool syncSucceeded = true;
try
{
var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
IEnumerable<ContainerObject> containerObjectList = cloudFilesProvider.ListObjects(container);
foreach (ContainerObject containerObject in containerObjectList)
{
cloudFilesProvider.GetObjectSaveToFile(container, localSource, containerObject.Name, containerObject.Name);
}
}
catch (Exception e)
{
Console.WriteLine("Exception in downloading from rackspace: " + e);
syncSucceeded = false;
}
return syncSucceeded;
}
示例4: Should_Create_Object_From_File_Without_Headers
public void Should_Create_Object_From_File_Without_Headers()
{
string filePath = Path.Combine(Directory.GetCurrentDirectory(), objectName);
string fileName = Path.GetFileName(filePath);
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider(_testIdentity);
provider.CreateObjectFromFile(containerName, filePath, fileName, 65536, headers, identity: _testIdentity);
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.AreEqual(fileName, containerGetObjectsResponse.Where(x => x.Name.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Name);
}
示例5: 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);
}
示例6: Should_Create_Object_From_Stream_Without_Headers
public void Should_Create_Object_From_Stream_Without_Headers()
{
string fileName = objectName;
Stream stream = System.IO.File.OpenRead(objectName);
stream.Position = 0;
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider(_testIdentity);
provider.CreateObject(containerName, stream, fileName, 65536, headers);
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.AreEqual(fileName, containerGetObjectsResponse.Where(x => x.Name.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Name);
}
示例7: Should_Throw_An_Exception_When_Calling_Get_Objects_From_Container_And_Objects_Does_Not_Exist
public void Should_Throw_An_Exception_When_Calling_Get_Objects_From_Container_And_Objects_Does_Not_Exist()
{
var provider = new CloudFilesProvider();
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.Fail("Expected exception was not thrown.");
}
示例8: Should_Get_Objects_From_Container
public void Should_Get_Objects_From_Container()
{
var provider = new CloudFilesProvider();
var containerGetObjectsResponse = provider.ListObjects(containerName, identity: _testIdentity);
Assert.IsNotNull(containerGetObjectsResponse);
}
示例9: Should_Bulk_Delete_All_Objects
public void Should_Bulk_Delete_All_Objects()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.BulkDelete(provider.ListObjects(containerName2).Select(o => string.Format("{0}/{1}", containerName2, o.Name)));
var objects = provider.ListObjects(containerName2).ToArray();
Assert.AreEqual(0, objects.Count());
}
示例10: Should_Delete_Object_But_Not_The_Segments
public void Should_Delete_Object_But_Not_The_Segments()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.DeleteObject(containerName2, objectName, deleteSegments: false);
var objects = provider.ListObjects(containerName2).ToArray();
Assert.AreEqual(11, objects.Count());
Assert.IsFalse(objects.Any(o => o.Name.Equals(objectName)));
for (int i = 0; i < 11; i++)
{
Assert.IsTrue(objects.Any(o => o.Name.Equals(string.Format("{0}.seg{1}", objectName, i.ToString("0000")))));
}
}
示例11: Should_Upload_File_In_Segments
public void Should_Upload_File_In_Segments()
{
var provider = new CloudFilesProvider(_testIdentity);
string filePath = Path.Combine(Directory.GetCurrentDirectory(), objectName);
provider.CreateObjectFromFile(containerName2, filePath);
var objects = provider.ListObjects(containerName2).ToArray();
Assert.AreEqual(12, objects.Count());
Assert.IsTrue(objects.Any(o => o.Name.Equals(objectName)));
for (int i = 0; i < 11; i++)
{
Assert.IsTrue(objects.Any(o => o.Name.Equals(string.Format("{0}.seg{1}", objectName, i.ToString("0000")))));
}
}
示例12: 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);
}
示例13: 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);
}
示例14: Should_Bulk_Delete_All_Objects
public void Should_Bulk_Delete_All_Objects()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.LargeFileBatchThreshold = 81920;
provider.BulkDelete(provider.ListObjects(containerName2).Select(o => new KeyValuePair<string, string>(containerName2, o.Name)));
var objects = provider.ListObjects(containerName2).ToArray();
Assert.AreEqual(0, objects.Count());
}
示例15: Should_Delete_Object_And_All_Segments
public void Should_Delete_Object_And_All_Segments()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.LargeFileBatchThreshold = 81920;
provider.DeleteObject(containerName2, objectName, deleteSegments: true);
var objects = provider.ListObjects(containerName2).ToArray();
Assert.AreEqual(0, objects.Count());
Assert.IsFalse(objects.Any(o => o.Name.Equals(objectName)));
for (int i = 0; i < 11; i++)
{
Assert.IsFalse(objects.Any(o => o.Name.Equals(string.Format("{0}.seg{1}", objectName, i.ToString("0000")))));
}
}