public void Should_Copy_Object_When_Passing_Content_Length()
        {
            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add(CloudFilesProvider.ContentLength, "62504");

            var provider = new CloudFilesProvider();
            var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, header, identity: _testIdentity);

            Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
        }
        public void Should_Copy_Object_When_Not_Passing_Content_Length_And_Passing_Expiring_Header()
        {
            // Object will expire 2 days from now.
            int epoch = (int)(DateTime.UtcNow.AddDays(2) - new DateTime(1970, 1, 1)).TotalSeconds;

            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add(CloudFilesProvider.ObjectDeleteAt, epoch.ToString());

            var provider = new CloudFilesProvider();
            var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, header, identity: _testIdentity);

            Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);

        }
        public void Should_Copy_Object_When_Not_Passing_Content_Length()
        {
            var provider = new CloudFilesProvider();
            var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, identity: _testIdentity);

            Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
        }
Esempio n. 4
0
        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);

        }
Esempio n. 5
0
        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);
        }
        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);
        }
 public void Should_Copy_Object_When_Not_Passing_Content_Length()
 {
     var provider = new CloudFilesProvider();
     provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, identity: _testIdentity);
 }