当前位置: 首页>>代码示例>>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;未经允许,请勿转载。