Ejemplo n.º 1
0
        public static void Main()
        {
            var client = new DropNetClient(DropboxAppKey, DropboxAppSecret);

            var token = client.GetToken();
            var url = client.BuildAuthorizeUrl();

            Console.WriteLine("COPY?PASTE Link: {0}", url);
            Console.WriteLine("Press enter when clicked allow");
            Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", url);

            Console.ReadLine();
            var accessToken = client.GetAccessToken();

            client.UseSandbox = true;
            var metaData = client.CreateFolder("NewUpload" + DateTime.Now.ToString());

            string[] dir = Directory.GetFiles("../../images/", "*.JPG");
            foreach (var item in dir)
            {
                Console.WriteLine("Reading file.....");
                FileStream stream = File.Open(item, FileMode.Open);
                var bytes = new byte[stream.Length];
                stream.Read(bytes, 0, (int)stream.Length);
                Console.WriteLine(bytes.Length + " bytes uploading...");
                client.UploadFile("/" + metaData.Name.ToString(), item.Substring(6), bytes);
                Console.WriteLine("{0} uploaded!", item);

                stream.Close();
            }
            Console.WriteLine("Job Done!");
            var picUrl = client.GetShare(metaData.Path);
            Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", picUrl.Url);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("You must first login in your dropbox account.");

            string currentDir = Directory.GetCurrentDirectory();
            DirectoryInfo info = new DirectoryInfo(currentDir).Parent.Parent;

            FileInfo[] pictures = info.GetFiles("*.jpg");

            List<int> indexesOfChosen = new List<int>();

            PrintAndChoosePictures(pictures, indexesOfChosen);

            DropNetClient client = new DropNetClient("8lc93q5ybq85syv", "nt6wrs7m0maixnl");

            var token = client.GetToken();
            var url = client.BuildAuthorizeUrl();

            Clipboard.SetText(url);

            Console.WriteLine("\n\nUrl copied to clipboard. Paste in browser and allow.\nPress any key to continue", url);
            Console.ReadKey(true);

            var accessToken = client.GetAccessToken();

            client.UserLogin.Secret = accessToken.Secret;
            client.UserLogin.Token = accessToken.Token;

            client.UseSandbox = true;


            Console.Write("Enter album name: ");
            var albumName = Console.ReadLine();

            var folder = client.CreateFolder(albumName);

            Console.WriteLine("\nUploading...\n");

            foreach (var i in indexesOfChosen)
            {
                MemoryStream sr = new MemoryStream((int)pictures[i].Length);
                FileStream fs = File.Open(pictures[i].FullName, FileMode.Open);
                
                var bytes = new byte[fs.Length];

                fs.Read(bytes, 0, Convert.ToInt32(fs.Length));

                client.UploadFile(folder.Path, pictures[i].Name, bytes);

                fs.Close();
            }

            var shareUrl = client.GetShare(folder.Path);

            Clipboard.SetText(shareUrl.Url);

            Console.WriteLine(shareUrl.Url);
            Console.WriteLine("Share Url is also in clipboard");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Uploads an album in dropbox client. 
        /// </summary>
        /// <param name="client">The dropbox client.</param>
        /// <returns></returns>
        private static ShareResponse UploadAlbum(DropNetClient client)
        {
            var folder = client.CreateFolder(ALBUM_NAME);
            DirectoryInfo info = new DirectoryInfo(ALBUM_FOLDER);
            FileInfo[] images = info.GetFiles(IMAGES_EXTENSION);

            UploadImages(client, folder, images);

            var shareUrl = client.GetShare(folder.Path);
            return shareUrl;
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            var client = new DropNetClient(apiKey, apiSecret);

            client.GetToken();
            var url = client.BuildAuthorizeUrl();

            Console.WriteLine("Open \"{0}\" in browser.", url);
            Console.WriteLine("Press [Enter] when you click on [Allow]");
            OpenBrowser(url);

            Console.ReadLine();
            client.GetAccessToken();

            client.UseSandbox = true;
            var metaData = client.CreateFolder("HW-Pictures - " + date);

            string[] dir = Directory.GetFiles("../../images/", "*.jpg");
            foreach (var file in dir)
            {
                Console.Write("Uploading");
                while (true)
                {
                    FileStream stream = File.Open(file, FileMode.Open);
                    var bytes = new byte[stream.Length];
                    stream.Read(bytes, 0, (int)stream.Length);

                    client.UploadFile("/" + metaData.Name, file.Substring(6), bytes);

                    for (var i = 0; i < 10; i++)
                    {
                        Console.Write(".");
                        Thread.Sleep(300);
                    }

                    stream.Close();

                    Console.WriteLine();
                    break;
                }
            }

            Console.WriteLine("Done!");
            var pictureUrl = client.GetShare(metaData.Path);
            OpenBrowser(pictureUrl.Url);
        }
Ejemplo n.º 5
0
        public static string UploadInDropbox(string fileName, Stream stream, int fileSize, bool isUserPicture = false)
        {
            DropNetClient client = new DropNetClient(DropboxAppKey, DropboxAppSecret, DropboxUserKey, DropboxUserSecret);
            client.UseSandbox = true;

            var bytes = new byte[fileSize];
            stream.Read(bytes, 0, fileSize);

            var currentTicks = DateTime.Now.Ticks;
            client.UploadFile("/", currentTicks + fileName, bytes);

            if (isUserPicture)
            {
                return client.GetMedia(string.Format("/{0}", currentTicks + fileName)).Url;
            }
            else
            {
                return client.GetShare(string.Format("/{0}", currentTicks + fileName)).Url;
            }
        }
        public static void Main()
        {
            var client = new DropNetClient(DropboxAppKey, DropboxAppSecret);

            var token = client.GetToken();
            var url = client.BuildAuthorizeUrl();

            Console.WriteLine("Open browser with in : {0}", url);
            Console.WriteLine("Press enter when clicked allow");
            Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
              url);

            Console.ReadLine();
            var accessToken = client.GetAccessToken();

            client.UseSandbox = true;
            var metaData = client.CreateFolder("Pictures" + DateTime.Now);

            var dir = Directory.GetFiles("../../Photos", "*.jpg");

            foreach (var item in dir)
            {
                Console.WriteLine("Uploading.....");
                var stream = File.Open(item, FileMode.Open);
                var bytes = new byte[stream.Length];
                stream.Read(bytes, 0, (int)stream.Length);

                client.UploadFile("/" + metaData.Name, item.Substring(6), bytes);

                stream.Close();
            }

            var picUrl = client.GetShare(metaData.Path);
            Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
             picUrl.Url);
        }
Ejemplo n.º 7
0
        internal static void Main(string[] args)
        {
            Console.WriteLine("Please login in your dropbox account.");
            Console.WriteLine(new string('-', 30));
            Console.Write("Press any key when ready");
            Console.ReadLine();
            Console.WriteLine(new string('-', 30));

            var currentDir = Directory.GetCurrentDirectory();
            var dirFiles = new DirectoryInfo(currentDir).Parent.Parent;

           var pictures = dirFiles.GetFiles("*.jpg");

           var chosenPhotosIndexes = new List<int>();

            PrintAndChoosePictures(pictures, chosenPhotosIndexes);

            DropNetClient client = new DropNetClient("0yfo5pqlswvwahb", "vi8gx0704m78ahy");

            var token = client.GetToken();
            var url = client.BuildAuthorizeUrl();

            Clipboard.SetText(url);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("App Url was copied to clipboard. Please paste it in your browser and click \"Allow\".");
            Console.WriteLine();
            Console.Write("Press any key when ready");
            Console.ReadKey(true);

            var accessToken = client.GetAccessToken();

            client.UserLogin.Secret = accessToken.Secret;
            client.UserLogin.Token = accessToken.Token;

            client.UseSandbox = true;

            Console.WriteLine();
            Console.Write("Please enter an album name: ");
            var albumName = Console.ReadLine();

            var folder = client.CreateFolder(albumName);

            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Uploading...");

            foreach (var index in chosenPhotosIndexes)
            {
                MemoryStream sr = new MemoryStream((int)pictures[index].Length);
                FileStream fs = File.Open(pictures[index].FullName, FileMode.Open);

                var bytes = new byte[fs.Length];

                fs.Read(bytes, 0, Convert.ToInt32(fs.Length));

                client.UploadFile(folder.Path, pictures[index].Name, bytes);

                fs.Close();
            }

            var shareUrl = client.GetShare(folder.Path);

            Clipboard.SetText(shareUrl.Url);

            Console.WriteLine("Url: {0}", shareUrl.Url);
            Console.WriteLine();
            Console.WriteLine("Sharing Url copied to clipboard. Enjoy the cat pics!");
        }