本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.DeleteContainer方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.DeleteContainer方法的具体用法?C# CloudFilesProvider.DeleteContainer怎么用?C# CloudFilesProvider.DeleteContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.DeleteContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CFProvidersDeleteContainer
protected void CFProvidersDeleteContainer(string cfdeletecontainername, 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 Cfdeletecontainer = CloudFilesProvider.DeleteContainer(cfdeletecontainername, dcregion, dcsnet);
}
示例2: TestContainerInvalidHeaderKeyCharacters
public void TestContainerInvalidHeaderKeyCharacters()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
ObjectStore result = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
List<char> validKeyCharList = new List<char>();
for (char i = MinHeaderKeyCharacter; i <= MaxHeaderKeyCharacter; i++)
{
if (!SeparatorCharacters.Contains(i) && !NotSupportedCharacters.Contains(i))
validKeyCharList.Add(i);
}
for (int i = char.MinValue; i <= char.MaxValue; i++)
{
if (validKeyCharList.BinarySearch((char)i) >= 0)
continue;
string invalidKey = new string((char)i, 1);
try
{
provider.UpdateContainerMetadata(
containerName,
new Dictionary<string, string>
{
{ invalidKey, "Value" }
});
Assert.Fail("Should throw an exception for invalid keys.");
}
catch (ArgumentException)
{
if (i >= MinHeaderKeyCharacter && i <= MaxHeaderKeyCharacter)
StringAssert.Contains(SeparatorCharacters, invalidKey);
}
catch (NotSupportedException)
{
StringAssert.Contains(NotSupportedCharacters, invalidKey);
}
}
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例3: TestContainerHeaderKeyCharacters
public void TestContainerHeaderKeyCharacters()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
ObjectStore result = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
List<char> keyCharList = new List<char>();
for (char i = MinHeaderKeyCharacter; i <= MaxHeaderKeyCharacter; i++)
{
if (!SeparatorCharacters.Contains(i) && !NotSupportedCharacters.Contains(i))
keyCharList.Add(i);
}
string key = TestKeyPrefix + new string(keyCharList.ToArray());
Console.WriteLine("Expected key: {0}", key);
provider.UpdateContainerMetadata(
containerName,
new Dictionary<string, string>
{
{ key, "Value" }
});
Dictionary<string, string> metadata = provider.GetContainerMetaData(containerName);
Assert.IsNotNull(metadata);
string value;
Assert.IsTrue(metadata.TryGetValue(key, out value));
Assert.AreEqual("Value", value);
provider.UpdateContainerMetadata(
containerName,
new Dictionary<string, string>
{
{ key, null }
});
metadata = provider.GetContainerMetaData(containerName);
Assert.IsNotNull(metadata);
Assert.IsFalse(metadata.TryGetValue(key, out value));
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例4: TestSpecialCharacters
public void TestSpecialCharacters()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string[] specialNames = { "#", " ", " lead", "trail ", "%", "x//x" };
// another random name counts as random content
string fileData = Path.GetRandomFileName();
foreach (string containerSuffix in specialNames)
{
string containerName = TestContainerPrefix + Path.GetRandomFileName() + containerSuffix;
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
foreach (string objectName in specialNames)
{
using (MemoryStream uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileData)))
{
provider.CreateObject(containerName, uploadStream, objectName);
}
}
Console.WriteLine("Objects in container {0}", containerName);
foreach (ContainerObject containerObject in ListAllObjects(provider, containerName))
{
Console.WriteLine(" {0}", containerObject.Name);
}
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
}
示例5: Should_Delete_Destination_Container
public void Should_Delete_Destination_Container()
{
var provider = new CloudFilesProvider();
var containerCreatedResponse = provider.DeleteContainer(destinationContainerName, identity: _testIdentity);
Assert.AreEqual(ObjectStore.ContainerDeleted, containerCreatedResponse);
}
示例6: DeleteContainer
private void DeleteContainer(CloudIdentity cloudIdentity, string container) {
var provider = new CloudFilesProvider(cloudIdentity);
provider.DeleteContainer(container: container, deleteObjects: true, region: fRegion);
}
示例7: TestUpdateObjectMetaData
public void TestUpdateObjectMetaData()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string objectName = Path.GetRandomFileName();
string objectData = "";
string contentType = "text/plain-jane";
ObjectStore result = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(objectData));
provider.CreateObject(containerName, stream, objectName, contentType);
Assert.AreEqual(contentType, GetObjectContentType(provider, containerName, objectName));
Dictionary<string, string> metadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Key1", "Value 1" },
{ "Key2", "Value ²" },
};
provider.UpdateObjectMetadata(containerName, objectName, new Dictionary<string, string>(metadata, StringComparer.OrdinalIgnoreCase));
Assert.AreEqual(contentType, GetObjectContentType(provider, containerName, objectName));
Dictionary<string, string> actualMetadata = provider.GetObjectMetaData(containerName, objectName);
Console.WriteLine("Object Metadata");
foreach (KeyValuePair<string, string> pair in actualMetadata)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
CheckMetadataCollections(metadata, actualMetadata);
metadata["Key2"] = "Value 2";
Dictionary<string, string> updatedMetadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Key2", "Value 2" }
};
provider.UpdateObjectMetadata(containerName, objectName, new Dictionary<string, string>(updatedMetadata, StringComparer.OrdinalIgnoreCase));
Assert.AreEqual(contentType, GetObjectContentType(provider, containerName, objectName));
actualMetadata = provider.GetObjectMetaData(containerName, objectName);
Console.WriteLine("Object Metadata");
foreach (KeyValuePair<string, string> pair in actualMetadata)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
CheckMetadataCollections(updatedMetadata, actualMetadata);
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例8: TestStaticWebOnContainer
public void TestStaticWebOnContainer()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string objectName = Path.GetRandomFileName();
string fileContents = "File contents!";
ObjectStore result = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
provider.CreateObject(containerName, stream, objectName);
Dictionary<string, string> cdnHeaders = provider.EnableCDNOnContainer(containerName, false);
Assert.IsNotNull(cdnHeaders);
Console.WriteLine("CDN Headers");
foreach (var pair in cdnHeaders)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
string index = objectName;
string error = objectName;
string css = objectName;
provider.EnableStaticWebOnContainer(containerName, index: index, error: error, listing: false);
provider.DisableStaticWebOnContainer(containerName);
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例9: TestCopyObject
public void TestCopyObject()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
string objectName = Path.GetRandomFileName();
string copiedName = Path.GetRandomFileName();
// another random name counts as random content
string fileData = Path.GetRandomFileName();
string contentType = "text/plain-jane";
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
using (MemoryStream uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileData)))
{
provider.CreateObject(containerName, uploadStream, objectName, contentType);
}
string actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
provider.CopyObject(containerName, objectName, containerName, copiedName);
// make sure the item is available at the copied location
actualData = ReadAllObjectText(provider, containerName, copiedName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
// make sure the original object still exists
actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
// make sure the content type was not changed by the copy operation
Assert.AreEqual(contentType, GetObjectContentType(provider, containerName, objectName));
Assert.AreEqual(contentType, GetObjectContentType(provider, containerName, copiedName));
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例10: TestGetObjectSaveToFile
public void TestGetObjectSaveToFile()
{
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);
}
try
{
provider.GetObjectSaveToFile(containerName, Path.GetTempPath(), objectName);
Assert.AreEqual(fileData, File.ReadAllText(Path.Combine(Path.GetTempPath(), objectName), Encoding.UTF8));
// it's ok to download the same file twice
ProgressMonitor progressMonitor = new ProgressMonitor(GetContainerObjectSize(provider, containerName, objectName));
provider.GetObjectSaveToFile(containerName, Path.GetTempPath(), objectName, progressUpdated: progressMonitor.Updated);
Assert.IsTrue(progressMonitor.IsComplete, "Failed to notify progress monitor callback of status update.");
}
finally
{
File.Delete(Path.Combine(Path.GetTempPath(), objectName));
}
string tempFileName = Path.GetRandomFileName();
try
{
provider.GetObjectSaveToFile(containerName, Path.GetTempPath(), objectName, tempFileName);
Assert.AreEqual(fileData, File.ReadAllText(Path.Combine(Path.GetTempPath(), tempFileName), Encoding.UTF8));
// it's ok to download the same file twice
ProgressMonitor progressMonitor = new ProgressMonitor(GetContainerObjectSize(provider, containerName, objectName));
provider.GetObjectSaveToFile(containerName, Path.GetTempPath(), objectName, progressUpdated: progressMonitor.Updated);
Assert.IsTrue(progressMonitor.IsComplete, "Failed to notify progress monitor callback of status update.");
}
finally
{
File.Delete(Path.Combine(Path.GetTempPath(), tempFileName));
}
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例11: 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);
}
}
}
}
示例12: 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);
}
示例13: TestCreateObject
public void TestCreateObject()
{
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);
// it's ok to create the same file twice
uploadStream.Position = 0;
ProgressMonitor progressMonitor = new ProgressMonitor(uploadStream.Length);
provider.CreateObject(containerName, uploadStream, objectName, progressUpdated: progressMonitor.Updated);
Assert.IsTrue(progressMonitor.IsComplete, "Failed to notify progress monitor callback of status update.");
}
string actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例14: TestCreateObjectFromFile_UseCustomObjectName
public void TestCreateObjectFromFile_UseCustomObjectName()
{
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();
string tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
ObjectStore containerResult = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);
try
{
File.WriteAllText(tempFilePath, fileData, Encoding.UTF8);
provider.CreateObjectFromFile(containerName, tempFilePath, objectName);
// it's ok to create the same file twice
ProgressMonitor progressMonitor = new ProgressMonitor(new FileInfo(tempFilePath).Length);
provider.CreateObjectFromFile(containerName, tempFilePath, objectName, progressUpdated: progressMonitor.Updated);
Assert.IsTrue(progressMonitor.IsComplete, "Failed to notify progress monitor callback of status update.");
}
finally
{
File.Delete(tempFilePath);
}
string actualData = ReadAllObjectText(provider, containerName, objectName, Encoding.UTF8);
Assert.AreEqual(fileData, actualData);
/* Cleanup
*/
provider.DeleteContainer(containerName, deleteObjects: true);
}
示例15: TestUpdateContainerMetadata
public void TestUpdateContainerMetadata()
{
IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
string containerName = TestContainerPrefix + Path.GetRandomFileName();
ObjectStore result = provider.CreateContainer(containerName);
Assert.AreEqual(ObjectStore.ContainerCreated, result);
Dictionary<string, string> metadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Key1", "Value 1" },
{ "Key2", "Value ²" },
};
provider.UpdateContainerMetadata(containerName, new Dictionary<string, string>(metadata, StringComparer.OrdinalIgnoreCase));
Dictionary<string, string> actualMetadata = provider.GetContainerMetaData(containerName);
Console.WriteLine("Container Metadata");
foreach (KeyValuePair<string, string> pair in actualMetadata)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
CheckMetadataCollections(metadata, actualMetadata);
metadata["Key2"] = "Value 2";
Dictionary<string, string> updatedMetadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Key2", "Value 2" }
};
provider.UpdateContainerMetadata(containerName, new Dictionary<string, string>(updatedMetadata, StringComparer.OrdinalIgnoreCase));
actualMetadata = provider.GetContainerMetaData(containerName);
Console.WriteLine("Container Metadata");
foreach (KeyValuePair<string, string> pair in actualMetadata)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
CheckMetadataCollections(metadata, actualMetadata);
provider.DeleteContainer(containerName, deleteObjects: true);
}