public string LoadImage(string path)
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            var place = "FeedbackSystemUploads";

            // Upload a file
            var   extension       = path.Split('.');
            var   imageName       = string.Format("{0}.{1}", DateTime.Now.Ticks, extension[extension.Length - 1]);
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(path),
                string.Format("/{0}/{1}", place, imageName)).Result;
            //Console.WriteLine("Uploaded a file: {0}", place);

            // Share a file
            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;

            Process.Start(sharedUrl.Url);

            return(imageName);
        }
예제 #2
0
        private static async Task <Entry> CreateFolderAsync(IDropbox dropbox, string newFolderName)
        {
            var createFolderEntry = await dropbox.CreateFolderAsync(newFolderName);

            Console.WriteLine("Created folder: {0}", createFolderEntry.Path);
            return(createFolderEntry);
        }
예제 #3
0
        private void Initialize()
        {
            try
            {
                Console.WriteLine("DropboxCoreService - Initialize - Initializing service...");
                var diskToken = LoadTokenFromDisk();
                var oauthAccessToken = new OAuthToken(diskToken.Value, diskToken.Secret);

                _dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);
                _dropbox = _dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
                //dropbox.Locale = CultureInfo.CurrentUICulture.IetfLanguageTag;
                HasLinkedAccount = true;
                Console.WriteLine("DropboxCoreService - Initialize - Finished initializing service!");
            }
            catch (AggregateException ae)
            {
                HasLinkedAccount = false;
                ae.Handle(ex =>
                {
                    if (ex is DropboxApiException)
                    {
                        Console.WriteLine("DropboxCoreService - Initialize - Exception: {0}", ex);
                        return true;
                    }
                    
                    // Ignore exceptions; if we cannot login on initialize, the user will have to relink the app later. 
                    // The UI should check the HasLinkedAccount property to see if Dropbox is available.
                    return true;
                });
            }
            catch (Exception ex)
            {
                // Ignore exceptions (see previous comment)
            }
        }        
예제 #4
0
        public string Upload(string file)
        {
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            // Display user name (from his profile)
            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            // Create new folder
            string newFolderName     = "New_Folder_" + DateTime.Now.Ticks;
            Entry  createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result;

            var    splitetFileDirectory = file.Split(new char[] { '/', '\\' });
            string fileName             = splitetFileDirectory[splitetFileDirectory.Length - 1];

            // Upload a file
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(file),                 //("../../DropboxExample.cs"),
                "/" + newFolderName + fileName).Result; //"/DropboxExample.cs").Result;

            // Share a file
            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;

            //Open the file location
            return(sharedUrl.Url.ToString());
        }
예제 #5
0
 private DropboxImageUploader()
 {
     this.dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.Full);
     this.oauthAccessToken       = new OAuthToken(OauthAccessTokenValue, OauthAccessTokenSecret); // this.oauthAccessToken = this.LoadOAuthToken();
     this.client  = new WebClient();
     this.dropbox = this.dropboxServiceProvider.GetApi(this.oauthAccessToken.Value, this.oauthAccessToken.Secret);
 }
        public override bool Ejecutar()
        {
            string consumerKey       = "dbhvzaf6ugr4k6q";
            string consumerSecret    = "q35bdvwgrut9bq4";
            string accessToken       = (usuario as Clases.Usuario).AccesToken;
            string accessTokenSecret = (usuario as Clases.Usuario).AccesSecret;
            bool   estado            = false;

            try
            {
                DropboxServiceProvider serviceProvider = new DropboxServiceProvider(consumerKey, consumerSecret, AccessLevel.AppFolder);
                IDropbox             dropboxApi        = serviceProvider.GetApi(accessToken, accessTokenSecret);
                var                  file        = dropboxApi.DownloadFileAsync("/RapidNote/" + nombre).Result;
                System.IO.FileStream _FileStream = new System.IO.FileStream(AppDomain.CurrentDomain.BaseDirectory + "Archivo\\" + nombre, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                _FileStream.Write(file.Content, 0, file.Content.Length);
                _FileStream.Close();
                Process.Start(AppDomain.CurrentDomain.BaseDirectory + "Archivo\\" + nombre);
                estado = true;
                return(estado);
            }
            catch (Exception ex)
            {
                return(estado);
            }
        }
예제 #7
0
        public static void Main()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            // Create new folder
            string newFolderName     = "Test";
            Entry  createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result;

            Console.WriteLine("Created folder: {0}", createFolderEntry.Path);

            // Upload a file
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource("../../cat.jpg"),
                "/" + newFolderName + "/cat.jpg").Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);

            // Share a file
            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;

            Process.Start(sharedUrl.Url);
        }
 private DropboxImageUploader()
 {
     this.dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.Full);
     this.oauthAccessToken = new OAuthToken(OauthAccessTokenValue, OauthAccessTokenSecret); // this.oauthAccessToken = this.LoadOAuthToken();
     this.client = new WebClient();
     this.dropbox = this.dropboxServiceProvider.GetApi(this.oauthAccessToken.Value, this.oauthAccessToken.Secret);
 }
예제 #9
0
        private IDropbox GetDropboxApi()
        {
            DropboxServiceProvider serviceProvider = this.Initialize(this.dropboxAppKey, this.dropboxAppSecret);
            IDropbox currentDropboxApi = serviceProvider.GetApi(this.oauthAccessToken.Value, this.oauthAccessToken.Secret);

            return currentDropboxApi;
        }
예제 #10
0
        public static void Main(string[] args)
        {
            // Pleace fill the DropboxAppKey and DropboxAppSecret with your credentionals before you test the app.
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            var oauthAccessToken = AuthorizeAppOAuth(dropboxServiceProvider);

            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            Console.WriteLine("Hi " + profile.DisplayName + "!");

            string newFolderName     = "Your_New_Images_Folder";
            Entry  createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result;

            var imageAsFileResource = new FileResource("../../Images/image1.jpg");
            var pathToUpload        = "/" + newFolderName + "/image1.jpg";

            Entry uploadFileEntry = dropbox.UploadFileAsync(imageAsFileResource, pathToUpload).Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);

            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;

            Process.Start(sharedUrl.Url);
        }
예제 #11
0
        public void UploadNewUserAvatar(string avatarLocalPath, string username)
        {
            dropbox = ConnectToDropboxAPI();

            string uploadPhotoName = String.Format("/{0}.jpg", username);

            uploadedPhoto = dropbox.UploadFileAsync(new FileResource(avatarLocalPath), uploadPhotoName).Result;
        }
예제 #12
0
 public FileManagerService(
     IDropbox dropbox,
     IMapper mapper,
     IUnitOfWork uow
     ) : base(mapper, uow)
 {
     _dropbox = dropbox;
 }
예제 #13
0
        public void UploadNewUserAvatar(string avatarLocalPath, string username)
        {
            dropbox = ConnectToDropboxAPI();

            string uploadPhotoName = String.Format("/{0}.jpg", username);

            uploadedPhoto = dropbox.UploadFileAsync(new FileResource(avatarLocalPath), uploadPhotoName).Result;
        }
예제 #14
0
        public static Entry UploadImage(string imagePath, IDropbox dropbox, string folderName)
        {
            string imageName = Path.GetFileName(imagePath);

            Entry uploadFileEntry = dropbox.UploadFileAsync(new FileResource(imagePath),
            "/" + folderName + "/" + imageName).Result;

            return uploadFileEntry;
        }
예제 #15
0
        private IDropbox Authenticate(DropboxServiceProvider dropboxServiceProvider, DropboxProvider provider, string OAuthTokenFileName)
        {
            OAuthToken oauthAccessToken = new OAuthToken("ng8ydj1aoljno9fk", "fyqdn9sv71fn8on");

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            return(dropbox);
        }
예제 #16
0
        public static Entry UploadImage(string imagePath, IDropbox dropbox, string folderName)
        {
            string imageName = Path.GetFileName(imagePath);

            Entry uploadFileEntry = dropbox.UploadFileAsync(new FileResource(imagePath),
                                                            "/" + folderName + "/" + imageName).Result;

            return(uploadFileEntry);
        }
예제 #17
0
        private static Entry CreateDropboxFolder(IDropbox dropbox, string folderName)
        {
            Entry folderEntry = dropbox
                .CreateFolderAsync(folderName)
                .Result;
            Console.WriteLine("Created folder: {0}", folderEntry.Path);

            return folderEntry;
        }
예제 #18
0
    private static string DropboxUpload(string fileUrl, IDropbox dropbox, string newFolderName)
    {
        Entry uploadFileEntry = dropbox.UploadFileAsync(
            new FileResource(fileUrl),
            "/" + newFolderName).Result;
        DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;

        return sharedUrl.Url;
    }
    public string UploadFile()
    {
        DropboxServiceProvider dropboxServiceProvider =
            new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

        // Authenticate the application (if not authenticated) and load the OAuth token
        //if (!File.Exists(OAuthTokenFileName))
        //{
        //    AuthorizeAppOAuth(dropboxServiceProvider);
        //}
        OAuthToken oauthAccessToken = new OAuthToken("fvjpvp0isfjsgyd7", "2u9zc9h1r0say01");

        // Login in Dropbox
        IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

        // Display user name (from his profile)
        DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

        Console.WriteLine("Hi " + profile.DisplayName + "!");

        // Create new folder
        string newFolderName = "RecipeImages";

        Directory.CreateDirectory("../../DropboxLisa");
        using (FileStream output = File.OpenWrite("../../DropboxLisa/" + DateTime.Now.Ticks + this.fileName))
        {
            CopyStream(imageStream, output);
        }

        // Upload a file
        string[]     files         = Directory.GetFiles("../../DropboxLisa");
        List <Entry> uploadedFiles = new List <Entry>();

        foreach (var file in files)
        {
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(Path.GetFullPath(file)),
                "/" + newFolderName + "/" + Path.GetFileName(file)).Result;
            uploadedFiles.Add(uploadFileEntry);
            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);
        }

        //Delete the file
        DeleteDirectory("\\DropboxLisa");


        string fileUrl = string.Empty;

        foreach (var file in uploadedFiles)
        {
            DropboxLink fileShareUrl = dropbox.GetMediaLinkAsync(file.Path).Result; // files
            fileUrl = fileShareUrl.Url;
        }

        return(fileUrl);
    }
예제 #20
0
        public DropboxService()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            IDropbox dropbox = dropboxServiceProvider.GetApi(appToken, appTokenSecret);

            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            this.currentDropbox = dropbox;
        }
        public DropboxService()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            IDropbox dropbox = dropboxServiceProvider.GetApi(appToken, appTokenSecret);

            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            this.currentDropbox = dropbox;
        }
예제 #22
0
        private static Entry UploadFileAsync(IDropbox dropbox, string targetFolderPath, string sourceFilePath)
        {
            var sourceFileName = Path.GetFileName(sourceFilePath);

            var uploadFileEntry = dropbox.UploadFileAsync(
                            new FileResource(sourceFilePath),
                            targetFolderPath + "/" + sourceFileName).Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);
            return uploadFileEntry;
        }
예제 #23
0
        private static Entry UploadFileAsync(IDropbox dropbox, string targetFolderPath, string sourceFilePath)
        {
            var sourceFileName = Path.GetFileName(sourceFilePath);

            var uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(sourceFilePath),
                targetFolderPath + "/" + sourceFileName).Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);
            return(uploadFileEntry);
        }
        // GET: /Dropbox/Browser
        public ActionResult Browser(string path)
        {
            string   tokenValue    = Session["TokenValue"] as string;
            string   tokenSecret   = Session["TokenSecret"] as string;
            IDropbox dropboxClient = dropboxProvider.GetApi(tokenValue, tokenSecret);
            //dropboxClient.Locale = System.Globalization.CultureInfo.CurrentUICulture.IetfLanguageTag; // for a localized version of the content response

            Entry root = dropboxClient.GetMetadataAsync(path).Result;

            return(View(root));
        }
예제 #25
0
 public CompanyService(
     ICompanyRepository companyRepository,
     IMapper mapper,
     IUnitOfWork uow,
     IDropbox dropbox,
     IFileManagerService fileManagerService
     ) : base(mapper, uow)
 {
     _companyRepository  = companyRepository;
     _dropbox            = dropbox;
     _fileManagerService = fileManagerService;
 }
예제 #26
0
        public static string DropboxShareFile(Stream stream, string filename)
        {
            //OAuthToken oauthAccessToken = LoadOAuthToken();
            IDropbox dropbox = dropboxServiceProvider.GetApi(oAuthToken[0], oAuthToken[1]);

            Entry uploadFileEntry = dropbox.UploadFileAsync(new StreamResource(stream)
                                                            , filename).Result;

            var sharedUrl = dropbox.GetMediaLinkAsync(uploadFileEntry.Path).Result;

            return(sharedUrl.Url + "?dl=1");  // we can download the file directly
        }
예제 #27
0
        private string DropboxShareFile(string path, string filename)
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(this.appAuth.Value, this.appAuth.Secret, AccessLevel.AppFolder);
            IDropbox dropbox = dropboxServiceProvider.GetApi(this.userAuth.Value, this.userAuth.Secret);

            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(path), filename).Result;

            var sharedUrl = dropbox.GetMediaLinkAsync(uploadFileEntry.Path).Result;

            return(sharedUrl.Url + "?dl=1");  // we can download the file directly
        }
        public void ShowProfile()
        {
            IDropbox dropboxClient = this.DropboxServiceProvider.GetApi(this.OAuthToken.Value, this.OAuthToken.Secret);

            dropboxClient.GetUserProfileAsync(
                r =>
            {
                if (r.Error == null)
                {
                    this.Profile = r.Response;
                }
            });
        }
예제 #29
0
        public static string AttachToPlace(string image, string address)
        {
            DropboxProvider dropboxProvider = new DropboxProvider();

            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            IDropbox dropbox = dropboxProvider.Authenticate(dropboxServiceProvider, dropboxProvider, OAuthTokenFileName);

            string resultUrl = dropboxProvider.TakeUrl(dropbox, image, address);

            return(resultUrl);
        }
예제 #30
0
        private static List<Entry> UploadFiles(IDropbox dataContext, string targetFolderPath, string sourceFolderPath)
        {
            var uploadedFileEntries = new List<Entry>();

            var filePaths = Directory.GetFiles(sourceFolderPath);
            foreach (var filePath in filePaths)
            {
                var uploadFileEntry = UploadFileAsync(dataContext, targetFolderPath, filePath);
                uploadedFileEntries.Add(uploadFileEntry);
            }

            return uploadedFileEntries;
        }
    private static void Main()
    {
        DropboxServiceProvider dropboxServiceProvider =
            new DropboxServiceProvider(AppKey, AppSecret, AccessLevel.AppFolder);

        if (!File.Exists(OAuthTokenFileName))
        {
            AuthorizeAppViaOAuth(dropboxServiceProvider);
        }

        OAuthToken oAuthAccessToken = LoadOAuthToken();

        IDropbox dropbox = dropboxServiceProvider.GetApi(oAuthAccessToken.Value, oAuthAccessToken.Secret);

        Entry  folderEntry = new Entry();
        string folderName  = string.Empty;

        while (true)
        {
            try
            {
                Console.WriteLine("Folder name:");
                folderName  = Console.ReadLine();
                folderEntry = dropbox.CreateFolderAsync(folderName).Result;
                Console.WriteLine("Folder '{0}' created.", folderEntry.Path);
                break;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }

        Console.WriteLine("Number of files to upload:");

        int filesCount = int.Parse(Console.ReadLine());

        for (int i = 0; i < filesCount; i++)
        {
            Console.WriteLine("File path:");
            string filePath        = Console.ReadLine().Trim();
            Entry  uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(filePath), "/" + folderName + "/" + Path.GetFileName(filePath)).Result;
            Console.WriteLine("File '{0}' uploaded.", uploadFileEntry.Path);
        }

        DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(folderEntry.Path).Result;

        Console.WriteLine(sharedUrl.Url);
        Process.Start(sharedUrl.Url);
    }
예제 #32
0
        private static List <Entry> UploadFiles(IDropbox dataContext, string targetFolderPath, string sourceFolderPath)
        {
            var uploadedFileEntries = new List <Entry>();

            var filePaths = Directory.GetFiles(sourceFolderPath);

            foreach (var filePath in filePaths)
            {
                var uploadFileEntry = UploadFileAsync(dataContext, targetFolderPath, filePath);
                uploadedFileEntries.Add(uploadFileEntry);
            }

            return(uploadedFileEntries);
        }
        // GET: /Dropbox/Callback
        public ActionResult Callback()
        {
            OAuthToken             requestToken           = Session["RequestToken"] as OAuthToken;
            AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, null);
            OAuthToken             token = dropboxProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result;

            Session["TokenValue"]  = token.Value;
            Session["TokenSecret"] = token.Secret;

            IDropbox       dropboxClient = dropboxProvider.GetApi(token.Value, token.Secret);
            DropboxProfile profile       = dropboxClient.GetUserProfileAsync().Result;

            return(View(profile));
        }
예제 #34
0
        static void Main()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            // Display user name (from his profile)
            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            Console.WriteLine("Hi " + profile.DisplayName + "!");

            // Create new folder
            string    newFolderName = "BatmanAlbum";
            DeltaPage deltaPage     = dropbox.DeltaAsync(null).Result;
            var       isFolderExist = deltaPage.Entries.Any(x => x.Path == ("/" + newFolderName).ToLower());

            if (!isFolderExist)
            {
                Entry createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result;
                Console.WriteLine("Created folder: {0}", createFolderEntry.Path);
            }

            var           folderPath     = @"../../Pics";
            DirectoryInfo picturesFolder = new DirectoryInfo(folderPath);

            foreach (var fileName in picturesFolder.GetFiles("*.jpg"))
            {
                // Upload a file
                Entry uploadFileEntry = dropbox.UploadFileAsync(
                    new FileResource(fileName.FullName),
                    "/" + newFolderName + "/" + fileName.Name).Result;
                Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);

                // Share a file
                DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;
                Process.Start(sharedUrl.Url);
            }
        }
예제 #35
0
        private void SendFile(string filePath)
        {
            OAuthToken oauthAccessToken = LoadOAuthToken();

            dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
            
            string newFolderName = "New_Folder_" + DateTime.Now.Ticks;
         
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource(filePath),
                "/" + newFolderName + "/" + new FileInfo(filePath).Name).Result;
            
            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(uploadFileEntry.Path).Result;
            Process.Start(sharedUrl.Url);

            MessageBox.Show("File sent successfully!");
        }
예제 #36
0
        public IDropbox ConnectToDropboxAPI()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            return dropbox;
        }
예제 #37
0
        static void Main()
        {
            IDropbox dataContext = GetDropboxContext();

            // Create new folder
            string newFolderName     = "SharedGallery" + DateTime.Now.Ticks;
            var    targetFolderEntry = CreateFolderAsync(dataContext, newFolderName).Result;

            // Upload files from local folder
            var sourceFolderPath = @"..\..\sourceImages";
            var uploadFileEntry  = UploadFiles(dataContext, targetFolderEntry.Path, sourceFolderPath);

            // Share the folder
            DropboxLink sharedUrl = dataContext.GetShareableLinkAsync(targetFolderEntry.Path).Result;

            Process.Start(sharedUrl.Url);
        }
예제 #38
0
        public IDropbox ConnectToDropboxAPI()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            return(dropbox);
        }
예제 #39
0
        static void Main()
        {
            DropboxServiceProvider dropboxServiceProvider =
                new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder);

            // Authenticate the application (if not authenticated) and load the OAuth token
            if (!File.Exists(OAuthTokenFileName))
            {
                AuthorizeAppOAuth(dropboxServiceProvider);
            }
            OAuthToken oauthAccessToken = LoadOAuthToken();

            // Login in Dropbox
            IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

            // Display user name (from his profile)
            DropboxProfile profile = dropbox.GetUserProfileAsync().Result;

            Console.WriteLine("Hi " + profile.DisplayName + "!");

            // Create new folder
            string newFolderName     = "PhotoAlbum_" + DateTime.Now.Ticks;
            Entry  createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result;

            Console.WriteLine("Created folder: {0}", createFolderEntry.Path);

            // Upload a file
            Entry uploadFileEntry = dropbox.UploadFileAsync(
                new FileResource("../../girl1.jpg"),
                "/" + newFolderName + "/girl1.jpg").Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);

            Entry uploadFileEntry2 = dropbox.UploadFileAsync(
                new FileResource("../../girl2.jpg"),
                "/" + newFolderName + "/girl12.jpg").Result;

            Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path);

            // Share a file
            DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(createFolderEntry.Path).Result;

            Process.Start(sharedUrl.Url);
        }
예제 #40
0
        private string TakeUrl(IDropbox dropbox, string image, string address)
        {
            // Create new folder
            // string newFolderName = "Test";
            // Entry createFolderEntry = dropbox.CreateFolder(newFolderName);
            //Console.WriteLine("Created folder: {0}", createFolderEntry.Path);

            HttpClient client = new HttpClient();

            byte[] imageAsByteArr = client.GetByteArrayAsync(address).Result;

            Entry uplodeImage = dropbox.UploadFile(new ByteArrayResource(imageAsByteArr), "/" + image);
            // Upload a file
            // Entry uploadFileEntry = dropbox.UploadFile(new FileResource("../../TestImages/" + image), "/" + image);

            // take url
            DropboxLink link = dropbox.GetMediaLink(uplodeImage.Path);
            string url = link.Url;
            return url;
        }
예제 #41
0
        private string TakeUrl(IDropbox dropbox, string image, string address)
        {
            // Create new folder
            // string newFolderName = "Test";
            // Entry createFolderEntry = dropbox.CreateFolder(newFolderName);
            //Console.WriteLine("Created folder: {0}", createFolderEntry.Path);

            HttpClient client = new HttpClient();

            byte[] imageAsByteArr = client.GetByteArrayAsync(address).Result;

            Entry uplodeImage = dropbox.UploadFile(new ByteArrayResource(imageAsByteArr), "/" + image);
            // Upload a file
            // Entry uploadFileEntry = dropbox.UploadFile(new FileResource("../../TestImages/" + image), "/" + image);

            // take url
            DropboxLink link = dropbox.GetMediaLink(uplodeImage.Path);
            string      url  = link.Url;

            return(url);
        }
예제 #42
0
        public override bool Ejecutar()
        {
            string consumerKey       = "dbhvzaf6ugr4k6q";
            string consumerSecret    = "q35bdvwgrut9bq4";
            string accessToken       = (usuario as Clases.Usuario).AccesToken;
            string accessTokenSecret = (usuario as Clases.Usuario).AccesSecret;
            bool   estado            = false;

            try
            {
                DropboxServiceProvider serviceProvider = new DropboxServiceProvider(consumerKey, consumerSecret, AccessLevel.AppFolder);
                IDropbox dropboxApi = serviceProvider.GetApi(accessToken, accessTokenSecret);
                dropboxApi.DeleteAsync("/RapidNote/" + nombre);
                estado = true;
                return(estado);
            }
            catch (Exception ex)
            {
                return(estado);
            }
        }
예제 #43
0
 public DropboxService()
 {
     this.dropboxAppKey = DropboxConstants.DropboxAppKey;
     this.dropboxAppSecret = DropboxConstants.DropboxAppSecret;
     this.dropboxApi = this.GetDropboxApi();
 }
예제 #44
0
 public DropboxService()
 {
     this.dropboxAppKey = WebStorageConstants.DropboxAppKey;
     this.dropboxAppSecret = WebStorageConstants.DropboxAppSecret;
     this.dropboxApi = this.GetDropboxApi();
 }
예제 #45
0
        private void ContinueLinkApp(AuthenticationToken token)
        {
            try
            {
                // Get access token either from parameter or from API
                OAuthToken oauthAccessToken = null;
                if (token == null)
                {
                    AuthorizedRequestToken requestToken = new AuthorizedRequestToken(_oauthToken, null);
                    oauthAccessToken = _dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                }
                else
                {
                    oauthAccessToken = new OAuthToken(token.Value, token.Secret);
                }

                if (OnCloudAuthenticationStatusChanged != null)
                    OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.RequestAccessToken);

                // Get Dropbox API instance
                _dropbox = _dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
                //dropbox.Locale = CultureInfo.CurrentUICulture.IetfLanguageTag;

                // Test Dropbox API connection (get user name from profile)
                DropboxProfile profile = _dropbox.GetUserProfileAsync().Result;
                HasLinkedAccount = true;

                // Save token to hard disk
                SaveTokenToDisk(new AuthenticationToken() {
                    Value = oauthAccessToken.Value, 
                    Secret = oauthAccessToken.Secret,
                    UserName = profile.DisplayName
                });
                
                if (OnCloudAuthenticationStatusChanged != null)
                    OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.ConnectedToDropbox);
            }
            catch (AggregateException ae)
            {
                HasLinkedAccount = false;
                ae.Handle(ex =>
                {
                    if (ex is DropboxApiException)
                    {
                        Console.WriteLine(ex.Message);
                        return true;
                    }
                    return false;
                });
            }
        }
예제 #46
0
 private static void Share(IDropbox dropbox, Entry fileOrFolderEntry)
 {
     DropboxLink sharedUrl = dropbox
                             .GetShareableLinkAsync(fileOrFolderEntry.Path)
                             .Result;
     Process.Start(sharedUrl.Url);
     Console.WriteLine("Folder {0} shared!", fileOrFolderEntry.Path);
 }
예제 #47
0
        private static void Upload(IDropbox dropbox, string path, string folderName)
        {
            DirectoryInfo directory = new DirectoryInfo(path);

            foreach (var file in directory.GetFiles())
            {
                Entry uploadFileEntry = dropbox
                    .UploadFileAsync(new FileResource(file.FullName), "/" + folderName + "/" + file.Name)
                    .Result;
                Console.WriteLine("Uploaded file: {0}", uploadFileEntry.Path);
            }
        }
예제 #48
0
 public DropBoxCloud(string key, string secret)
 {
     this.dropboxAppKey = key;
     this.dropboxAppSecret = secret;
     this.dropboxApi = this.GetDropboxApi();
 }
예제 #49
0
 public void UnlinkApp()
 {
     DeleteTokenFromDisk();
     HasLinkedAccount = false;
     _dropbox = null;
 }
예제 #50
0
 public DropboxHelper()
 {
     this.serviceProvider = new DropboxServiceProvider(Constants.DropboxAppKey, Constants.DropboxAppSecret, AccessLevel.AppFolder);
     this.dropbox = serviceProvider.GetApi(Constants.DropboxAppToken, Constants.DropboxAppTokenSecret);
 }
예제 #51
0
 private static async Task<Entry> CreateFolderAsync(IDropbox dropbox, string newFolderName)
 {
     var createFolderEntry = await dropbox.CreateFolderAsync(newFolderName);
     Console.WriteLine("Created folder: {0}", createFolderEntry.Path);
     return createFolderEntry;
 }