當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudFilesProvider.GetObjectHeaders方法代碼示例

本文整理匯總了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.GetObjectHeaders方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudFilesProvider.GetObjectHeaders方法的具體用法?C# CloudFilesProvider.GetObjectHeaders怎麽用?C# CloudFilesProvider.GetObjectHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.openstack.Providers.Rackspace.CloudFilesProvider的用法示例。


在下文中一共展示了CloudFilesProvider.GetObjectHeaders方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_Throw_Exception_When_Calling_Get_Headers_For_Object_And_Object_Name_Is_Empty

        public void Should_Throw_Exception_When_Calling_Get_Headers_For_Object_And_Object_Name_Is_Empty()
        {
            string objectNameLocal = string.Empty;
            var provider = new CloudFilesProvider();
            var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectNameLocal, identity: _testIdentity);

            Assert.Fail("Expected exception was not thrown.");
        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:8,代碼來源:CloudFilesTests.cs

示例2: 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);
        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:33,代碼來源:CloudFilesTests.cs

示例3: Should_Copy_Object_When_Not_Passing_Content_Length_And_Passing_Expiring_Header

        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);

        }
開發者ID:jonwalton,項目名稱:openstack.net,代碼行數:19,代碼來源:CloudFilesTests.cs

示例4: Should_Get_Headers_For_Object

        public void Should_Get_Headers_For_Object()
        {

            var provider = new CloudFilesProvider();
            var objectHeadersResponse = provider.GetObjectHeaders(containerName, objectName, identity: _testIdentity);

            Assert.IsNotNull(objectHeadersResponse);
            //Assert.AreEqual("Christian Bale", objectHeadersResponse.Where(x => x.Key.Equals("X-Object-Meta-Actor", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);
        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:9,代碼來源:CloudFilesTests.cs

示例5: Should_Copy_Object_When_Passing_Content_Length

        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);
        }
開發者ID:jonwalton,項目名稱:openstack.net,代碼行數:13,代碼來源:CloudFilesTests.cs

示例6: TestGetObjectHeaders

        public void TestGetObjectHeaders()
        {
            IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
            string containerName = TestContainerPrefix + Path.GetRandomFileName();
            string objectName = Path.GetRandomFileName();
            string objectData = "";

            ObjectStore containerResult = provider.CreateContainer(containerName);
            Assert.AreEqual(ObjectStore.ContainerCreated, containerResult);

            Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(objectData));
            provider.CreateObject(containerName, stream, objectName);
            Dictionary<string, string> headers = provider.GetObjectHeaders(containerName, objectName);
            Assert.IsNotNull(headers);
            Console.WriteLine("Headers");
            foreach (var pair in headers)
            {
                Assert.IsFalse(string.IsNullOrEmpty(pair.Key));
                Console.WriteLine("  {0}: {1}", pair.Key, pair.Value);
            }

            provider.DeleteContainer(containerName, deleteObjects: true);
        }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:23,代碼來源:UserObjectStorageTests.cs

示例7: 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);
        }
開發者ID:brendanseabrook,項目名稱:openstack.net,代碼行數:16,代碼來源:CloudFilesTests.cs

示例8: 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);
        }
開發者ID:brendanseabrook,項目名稱:openstack.net,代碼行數:18,代碼來源:CloudFilesTests.cs


注:本文中的net.openstack.Providers.Rackspace.CloudFilesProvider.GetObjectHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。