public CloudFilesUploadService(string username, string apiKey, string containerName)
 {
     this.authUserName = username;
     this.authKey = apiKey;
     this.containerName = containerName;
     cfConnection = new Connection(new UserCredentials(authUserName, authKey));
 }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            Boolean b = false;

            if (args.Length != 4) {
                Console.WriteLine("Usage: username api_key container object");
                Environment.Exit(1);
            }

            username = args[0];
            api_key = args[1];
            chosenContainer = args[2];
            filePath = args[3];

            UserCredentials userCreds = new UserCredentials(username, api_key);
            Connection connection = new com.mosso.cloudfiles.Connection(userCreds);

            List<string> containers = connection.GetContainers();

            foreach (string container in containers) {
                if (container == chosenContainer)
                    b = true;
            }

            if (!b) {
                Console.WriteLine("Container {0} does not seem to exist.", chosenContainer);
                Environment.Exit(1);
            }

            if (!File.Exists(filePath)) {
                Console.WriteLine("fileName {0} does not seem to exist.", filePath);
                Environment.Exit(1);
            }

            FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            connection.PutStorageItem(chosenContainer, fileStream, Path.GetFileName(filePath));
            Console.WriteLine("*success* uploaded");
        }
Ejemplo n.º 3
0
        private void CheckAuthentication()
        {
            if (username.Length == 0 || api_access_key.Length == 0)
            {
                CredentialsDialog credentialsDialog = new CredentialsDialog();
                System.Windows.Forms.DialogResult dialogResult = credentialsDialog.ShowDialog(this);

                if (dialogResult != DialogResult.OK) return;

                if (dialogResult == DialogResult.OK)
                {
                    username = credentialsDialog.Username;
                    api_access_key = credentialsDialog.ApiAccessKey;
                    deleteAllContainersButton.Enabled = true;
                }

                try
                {
                    Connection = new Connection(new UserCredentials(username, api_access_key));
                    RetrieveContainers();
                }
                catch
                {
                    MessageBox.Show("Authentication failed");
                    Form1_Load(this, new EventArgs());
                }
            }
        }
Ejemplo n.º 4
-1
        private void CheckAuthentication()
        {
            if (username.Length == 0 || api_access_key.Length == 0)
            {
                CredentialsDialog credentialsDialog = new CredentialsDialog();
                System.Windows.Forms.DialogResult dialogResult = credentialsDialog.ShowDialog(this);

                if (dialogResult != DialogResult.OK) return;

                if (dialogResult == DialogResult.OK)
                {
                    username = credentialsDialog.Username;
                    api_access_key = credentialsDialog.ApiAccessKey;
                    auth_endpoint = credentialsDialog.AuthEndpoint;

                    if (auth_endpoint.Length == 0)
                    {
                        auth_endpoint = "https://auth.api.rackspacecloud.com/v1.0";
                    }
                    deleteAllContainersButton.Enabled = true;

                }

                try
                {
                    Connection = new Connection(new UserCredentials(new System.Uri(auth_endpoint),username, api_access_key, null, null));
                    RetrieveContainers();
                }
                catch
                {
                    MessageBox.Show("Authentication failed");
                    Form1_Load(this, new EventArgs());
                }
            }
        }