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


C# CloudFilesProvider.GetObjectSaveToFile方法代碼示例

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


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

示例1: DownloadFromRackSpaceCloudFiles

        public bool DownloadFromRackSpaceCloudFiles()
        {
            bool syncSucceeded = true;
            try
            {
                var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
                var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
                IEnumerable<ContainerObject> containerObjectList = cloudFilesProvider.ListObjects(container);

                foreach (ContainerObject containerObject in containerObjectList)
                {
                    cloudFilesProvider.GetObjectSaveToFile(container, localSource, containerObject.Name, containerObject.Name);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in downloading from rackspace: " + e);
                syncSucceeded = false;
            }
            return syncSucceeded;
        }
開發者ID:smosgin,項目名稱:labofthings,代碼行數:21,代碼來源:RackspaceCloudFilesSynchronizer.cs

示例2: Should_Get_Object_And_Save_To_File_Without_Headers_And_Verify_Etag

 public void Should_Get_Object_And_Save_To_File_Without_Headers_And_Verify_Etag()
 {
     string filePath = Path.Combine(Directory.GetCurrentDirectory(), objectName);
     string fileName = Path.GetFileName(filePath);
     var headers = new Dictionary<string, string>();
     var provider = new CloudFilesProvider();
     provider.GetObjectSaveToFile(containerName, saveDirectory, fileName, null, 65536, null, null, true, identity: _testIdentity);
 }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:8,代碼來源:CloudFilesTests.cs

示例3: Should_Get_Object_And_Save_To_File_Without_Headers_And_Verify_Etag

 public void Should_Get_Object_And_Save_To_File_Without_Headers_And_Verify_Etag()
 {
     var provider = new CloudFilesProvider(_testIdentity);
     provider.GetObjectSaveToFile(containerName, Directory.GetCurrentDirectory(), objectName, saveFileNane2, verifyEtag: true);
 }
開發者ID:jonwalton,項目名稱:openstack.net,代碼行數:5,代碼來源:CloudFilesTests.cs

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


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