Example #1
0
        static void Main()
        {
            DropboxHelper dh = new DropboxHelper();

            // check if it is Up & Running
            // Lists all files in profiles folder
            dh.Run().Wait();

            // download file with specific name from profiles folder
            // saves it in bin/debug
            dh.Download("pesho.bmp").Wait();

            try
            {
                dh.Download("jm.bmp").Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // upload file with specific name from
            // bin/debug
            dh.UploadProfilePicture("gosho.bmp").Wait();
        }
Example #2
0
        private void loginForm_Load(object sender, EventArgs e)
        {
            this.parent = (MainForm)this.MdiParent;
            this.parent.StatusLabel = this.LABEL;
            this.URI_TOKEN = new Uri(this.parent.BaseLink + "Token");

            //Dropbox downloader
            try
            {
                string imageLocation = "avatar.png";

                DropboxHelper dh = new DropboxHelper();

                BackgroundWorker bgw = new BackgroundWorker();
                bgw.DoWork += delegate
                {
                    dh.Run().Wait();
                    dh.Download(imageLocation).Wait();

                    using (var fs = new System.IO.FileStream(imageLocation, System.IO.FileMode.Open))
                    {
                        var bmp = new Bitmap(fs);
                        this.pictureBox.Image = (Bitmap)bmp.Clone();
                    }

                    MessageBox.Show("Downloaded pic from dropbox.", "Success");
                };

                bgw.RunWorkerAsync();
            }
            catch
            {
                //silent excception
            }
        }
Example #3
0
        private void loginForm_Load(object sender, EventArgs e)
        {
            this.parent             = (MainForm)this.MdiParent;
            this.parent.StatusLabel = this.LABEL;
            this.URI_TOKEN          = new Uri(this.parent.BaseLink + "Token");

            //Dropbox downloader
            try
            {
                string imageLocation = "avatar.png";

                DropboxHelper dh = new DropboxHelper();

                BackgroundWorker bgw = new BackgroundWorker();
                bgw.DoWork += delegate
                {
                    dh.Run().Wait();
                    dh.Download(imageLocation).Wait();

                    using (var fs = new System.IO.FileStream(imageLocation, System.IO.FileMode.Open))
                    {
                        var bmp = new Bitmap(fs);
                        this.pictureBox.Image = (Bitmap)bmp.Clone();
                    }

                    MessageBox.Show("Downloaded pic from dropbox.", "Success");
                };

                bgw.RunWorkerAsync();
            }
            catch
            {
                //silent excception
            }
        }
Example #4
0
        private string ConvertPath(string path)
        {
            int lastSlash = path.LastIndexOf('/');

            string folder = path.Substring(0, lastSlash);
            string file   = path.Substring(lastSlash);

            using (var dbx = new DropboxClient(DropboxHelper.AccessToken))
            {
                byte[] imageByteData   = DropboxHelper.Download(dbx, folder, file);
                string imageBase64Data = Convert.ToBase64String(imageByteData);
                string imageDataURL    = string.Format("data:image/png;base64,{0}", imageBase64Data);

                return(imageDataURL);
            }
        }