本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.DeleteObject方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.DeleteObject方法的具体用法?C# CloudFilesProvider.DeleteObject怎么用?C# CloudFilesProvider.DeleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.DeleteObject方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CFProvidersDeleteContainerObject
protected void CFProvidersDeleteContainerObject(string cfcontainername, string cfdeletecontainerobject, 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 Cfdeletecontainerobject = CloudFilesProvider.DeleteObject(cfcontainername, cfdeletecontainerobject, null, dcregion, dcsnet);
}
示例2: Should_Throw_An_Exception_When_Deleting_Object
public void Should_Throw_An_Exception_When_Deleting_Object()
{
// TODO: Also need to make 404 as an acceptable status.
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider();
var deleteResponse = provider.DeleteObject(containerName, objectName, headers, identity: _testIdentity);
Assert.Fail("Expected exception was not thrown.");
}
示例3: 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")))));
}
}
示例4: Should_Delete_Object_On_Destination_Container
public void Should_Delete_Object_On_Destination_Container()
{
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider();
var deleteResponse = provider.DeleteObject(destinationContainerName, destinationObjectName, headers, identity: _testIdentity);
Assert.AreEqual(ObjectStore.ObjectDeleted, deleteResponse);
}
示例5: TestVersionedContainer
public void TestVersionedContainer()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string versionsContainerName = TestContainerPrefix + Path.GetRandomFileName();
ObjectStore result = provider.CreateContainer(versionsContainerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
result = provider.CreateContainer(containerName, new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { CloudFilesProvider.VersionsLocation, versionsContainerName } });
Assert.AreEqual(ObjectStore.ContainerCreated, result);
Dictionary<string, string> headers = provider.GetContainerHeader(containerName);
string location;
Assert.IsTrue(headers.TryGetValue(CloudFilesProvider.VersionsLocation, out location));
Assert.AreEqual(versionsContainerName, location);
string objectName = Path.GetRandomFileName();
string fileData1 = "first-content";
string fileData2 = "second-content";
/*
* Create the object
*/
using (MemoryStream uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileData1)))
{
provider.CreateObject(containerName, uploadStream, objectName);
}
string actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData1, actualData);
/*
* Overwrite the object
*/
using (MemoryStream uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileData2)))
{
provider.CreateObject(containerName, uploadStream, objectName);
}
actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData2, actualData);
/*
* Delete the object once
*/
provider.DeleteObject(containerName, objectName);
actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData1, actualData);
/*
* Cleanup
*/
provider.DeleteContainer(versionsContainerName, deleteObjects: true);
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例6: DeleteObject
private void DeleteObject(CloudIdentity cloudIdentity, string container, string objectname) {
var provider = new CloudFilesProvider(cloudIdentity);
provider.DeleteObject(container: container, objectName: objectname, region: fRegion);
}
示例7: 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);
}
示例8: CleanupTestContainers
public void CleanupTestContainers()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
IEnumerable<Container> containers = ListAllContainers(provider);
foreach (Container container in containers)
{
if (container.Name.StartsWith(TestContainerPrefix))
{
try
{
provider.DeleteContainer(container.Name, deleteObjects: true);
}
catch (ContainerNotEmptyException)
{
// this works around a bug in bulk delete, where files with trailing whitespace
// in the name do not get deleted
foreach (ContainerObject containerObject in ListAllObjects(provider, container.Name))
provider.DeleteObject(container.Name, containerObject.Name);
provider.DeleteContainer(container.Name, deleteObjects: false);
}
}
else if (container.Name.Equals(".CDN_ACCESS_LOGS"))
{
foreach (ContainerObject containerObject in ListAllObjects(provider, container.Name))
{
if (containerObject.Name.StartsWith(TestContainerPrefix))
provider.DeleteObject(container.Name, containerObject.Name);
}
}
}
}
示例9: 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")))));
}
}
示例10: Should_Delete_Object_On_Destination_Container
public void Should_Delete_Object_On_Destination_Container()
{
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider();
provider.DeleteObject(destinationContainerName, destinationObjectName, headers, identity: _testIdentity);
}
示例11: Should_Delete_Object
public void Should_Delete_Object()
{
string fileName = objectName;
var headers = new Dictionary<string, string>();
var provider = new CloudFilesProvider();
provider.DeleteObject(containerName, fileName, headers, identity: _testIdentity);
}