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);
        }
        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.");
        }
Exemplo n.º 3
0
        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")))));
            }
        }
        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);
        }
        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);
        }
Exemplo n.º 6
0
 private void DeleteObject(CloudIdentity cloudIdentity, string container, string objectname) {
     var provider = new CloudFilesProvider(cloudIdentity);
     provider.DeleteObject(container: container, objectName: objectname, region: fRegion);
 }
        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);
        }
        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);
                    }
                }
            }
        }
        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")))));
            }
        }
 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);
 }
 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);
 }