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


C# Rackspace.CloudFilesProvider類代碼示例

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


CloudFilesProvider類屬於net.openstack.Providers.Rackspace命名空間,在下文中一共展示了CloudFilesProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            Console.WriteLine();
            if (ParseArguments(args))
            {
                DirectoryInfo directory = null;

                try
                {
                    directory = new DirectoryInfo(Source);
                    if (!directory.Exists)
                    {
                        throw new Exception(String.Format("Source directory does not exist\n{0}", Source));
                    }
                }
                catch (Exception ex)
                {
                    PrintException(ex);
                }

                Console.WriteLine(String.Format("Source directory: {0}", Source));
                Console.WriteLine(String.Format("Destination container: {0}", Container));
                Console.WriteLine("Logging in...");
                Console.WriteLine();

                if (Login())
                {
                    var cloudFiles = new CloudFilesProvider(auth);

                    try
                    {
                        switch (cloudFiles.CreateContainer(Container))
                        {
                            case ObjectStore.ContainerCreated:
                            case ObjectStore.ContainerExists:
                                foreach (var file in directory.GetFiles())
                                {
                                    Console.WriteLine(String.Format("{0,3:0}% Uploading: {1}", 0, file.Name));
                                    cloudFiles.CreateObjectFromFile(Container, file.FullName, progressUpdated: delegate(long p)
                                    {
                                        Console.SetCursorPosition(0, Console.CursorTop -1);
                                        Console.WriteLine(String.Format("{0,3:0}% Uploading: {1}", ((float)p / (float)file.Length) * 100, file.Name));
                                    });
                                }
                                break;
                            default:
                                throw new Exception(String.Format("Unknown error when creating container {0}", Container));
                        }
                    }
                    catch (Exception ex)
                    {
                        PrintException(ex);
                    }
                }
            }

            Console.WriteLine();
            Console.Write("Press any key to exit");
            Console.ReadKey();
        }
開發者ID:jonwalton,項目名稱:cloud_code_samples,代碼行數:60,代碼來源:Program.cs

示例2: Should_Return_Container_List_With_Internal_Url

        public void Should_Return_Container_List_With_Internal_Url()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(useInternalUrl:true, identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.IsTrue(containerList.Any());
        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:8,代碼來源:CloudFilesTests.cs

示例3: Should_Return_Container_List

        public void Should_Return_Container_List()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.IsTrue(containerList.Any());
        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:8,代碼來源:CloudFilesTests.cs

示例4: CFProvidersCreateContainer

        protected void CFProvidersCreateContainer(string cfcreatecontainername, 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 CfCreateContainer = CloudFilesProvider.CreateContainer(cfcreatecontainername, dcregion, dcsnet);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例5: CFProvidersCreateObjectFromFile

        protected void CFProvidersCreateObjectFromFile(string cfcontainername, string cfcreateobjfilepath, string cfcreateobjfilename, int cfcreateobjchunksize, 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);

            CloudFilesProvider.CreateObjectFromFile(cfcontainername, cfcreateobjfilepath, cfcreateobjfilename, cfcreateobjchunksize, null, dcregion, null, dcsnet);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例6: CFProvidersDeleteContainerObject

        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);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例7: CloudFilesContainerNode

        public CloudFilesContainerNode(CloudFilesProvider provider, Container container, ContainerCDN containerCdn)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (container == null)
                throw new ArgumentNullException("container");

            _provider = provider;
            _container = container;
            _containerCdn = containerCdn;
        }
開發者ID:rackerlabs,項目名稱:rax-vsix,代碼行數:11,代碼來源:CloudFilesContainerNode.cs

示例8: CloudFilesTests

        public CloudFilesTests(ITestOutputHelper testLog)
        {
            var testOutput = new XunitTraceListener(testLog);
            Trace.Listeners.Add(testOutput);
            OpenStackNet.Tracing.Http.Listeners.Add(testOutput);

            var authenticationProvider = TestIdentityProvider.GetIdentityProvider();
            authenticationProvider.Authenticate();

            _cloudFiles = new CloudFilesProvider(null, authenticationProvider);
        }
開發者ID:ravikamachi,項目名稱:openstack.net,代碼行數:11,代碼來源:CloudFilesProviderTests.cs

示例9: CloudFilesObjectNode

        public CloudFilesObjectNode(CloudFilesProvider provider, Container container, ContainerObject containerObject)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (container == null)
                throw new ArgumentNullException("container");
            if (containerObject == null)
                throw new ArgumentNullException("containerObject");

            _provider = provider;
            _container = container;
            _containerObject = containerObject;
        }
開發者ID:rackerlabs,項目名稱:rax-vsix,代碼行數:13,代碼來源:CloudFilesObjectNode.cs

示例10: CFProviderListContainers

        protected void CFProviderListContainers(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 CfContainers = CloudFilesProvider.ListContainers(null, null, null, dcregion, dcsnet);

            CFContainerDDL.DataSource = CfContainers;
            CFContainerDDL.DataTextField = "Name";
            CFContainerDDL.DataBind();
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:13,代碼來源:CloudFiles.aspx.cs

示例11: ListContainer

        private IEnumerable<ContainerObject> ListContainer(CloudIdentity cloudIdentity, string container, int? limit = null, string prefix = null, string region = null, bool useInternalUrl = false) {
            var provider = new CloudFilesProvider(cloudIdentity);

            ContainerObject lastContainerObject = null;

            do {
                string marker = lastContainerObject != null ? lastContainerObject.Name : null;
                IEnumerable<ContainerObject> containerObjects = provider.ListObjects(container, limit, marker, null, prefix, region, useInternalUrl, cloudIdentity);
                lastContainerObject = null;
                foreach (ContainerObject containerObject in containerObjects) {
                    lastContainerObject = containerObject;
                    yield return containerObject;
                }
            } while (lastContainerObject != null);

        }
開發者ID:pjcunningham,項目名稱:SwiftClient.Net,代碼行數:16,代碼來源:Provider.cs

示例12: 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

示例13: RackspaceCloudFilesSynchronizer

        public RackspaceCloudFilesSynchronizer(RemoteInfo ri, string container, SynchronizeDirection syncDirection)
        {
            this.disposed = false;
            this.username = ri.accountName;
            this.apiKey = ri.accountKey;
            this.syncDirection = syncDirection;
            this.container = container;
            try
            {
                var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
                var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
                ObjectStore createContainerResponse = cloudFilesProvider.CreateContainer(container);// assume default region for now

                if (!createContainerResponse.Equals(ObjectStore.ContainerCreated) && !createContainerResponse.Equals(ObjectStore.ContainerExists))
                    Console.WriteLine("Container creation failed! Response: " + createContainerResponse.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in creating container: " + e);
            }
        }
開發者ID:smosgin,項目名稱:labofthings,代碼行數:21,代碼來源:RackspaceCloudFilesSynchronizer.cs

示例14: Authenticate

        //Method to Authenticate the credentials and obtain token
        public void Authenticate()
        {
            try
            {
                //Creating an instance of CloudIdentityProvider providing the CloudIdentity object and urls in the constructor
                provider = new CloudIdentityProvider(identity, "https://identity.api.rackspacecloud.com/v1.0", "https://lon.identity.api.rackspacecloud.com/v1.0");
                //Calling the authenticate method which returns an UserAccess object containing token and user details
                UserAccess access = provider.Authenticate(identity);

                token = access.Token;

                userdetails = access.User;
                //Set the TokenId property
                TokenId = token.Id;
                //Verify with other programmers to make this method void
                cloudFiles = new CloudFilesProvider(identity);
                //return token.Id;
            }

            catch (UserAuthenticationException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (UserAuthorizationException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (UserNotAuthorizedException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
開發者ID:vcholan,項目名稱:generic-cloud-storage-client,代碼行數:41,代碼來源:Rackspace.cs

示例15: CKEditorUpload

        public ActionResult CKEditorUpload(string CKEditorFuncNum)
        {
            var m = new AccountModel();
            string baseurl = null;
            if (Request.Files.Count == 0)
                return Content("");
            var file = Request.Files[0];
            var fn = $"{DbUtil.Db.Host}.{DateTime.Now:yyMMddHHmm}.{m.CleanFileName(Path.GetFileName(file.FileName))}";
            var error = string.Empty;
            var rackspacecdn = ConfigurationManager.AppSettings["RackspaceUrlCDN"];

            if (rackspacecdn.HasValue())
            {
                baseurl = rackspacecdn;
                var username = ConfigurationManager.AppSettings["RackspaceUser"];
                var key = ConfigurationManager.AppSettings["RackspaceKey"];
                var cloudIdentity = new CloudIdentity {APIKey = key, Username = username};
                var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
                cloudFilesProvider.CreateObject("AllFiles", file.InputStream, fn);
            }
            else // local server
            {
                baseurl = $"{Request.Url.Scheme}://{Request.Url.Authority}/Upload/";
                try
                {
                    var path = Server.MapPath("/Upload/");
                    path += fn;

                    path = m.GetNewFileName(path);
                    file.SaveAs(path);
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                    baseurl = string.Empty;
                }
            }
            return Content($"<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction( {CKEditorFuncNum}, '{baseurl + fn}', '{error}' );</script>");
        }
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:39,代碼來源:AccountController.cs


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