public void UploadNewUserAvatar(string avatarLocalPath, string username) { dropbox = ConnectToDropboxAPI(); string uploadPhotoName = String.Format("/{0}.jpg", username); uploadedPhoto = dropbox.UploadFileAsync(new FileResource(avatarLocalPath), uploadPhotoName).Result; }
static void Main() { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); if (!File.Exists(OAuthTokenFileName)) { AuthorizeAppOAuth(dropboxServiceProvider); } OAuthToken oauthAccessToken = LoadOAuthToken(); IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); Entry createFolderEntry = new Entry(); string newFolderName = string.Empty; while (true) { try { Console.WriteLine("Please enter name of photo album folder"); newFolderName = Console.ReadLine(); createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result; Console.WriteLine("Created folder: {0}", createFolderEntry.Path); break; } catch (Exception ex) { Console.WriteLine("This folder already exists; " + ex.InnerException.Message); } } Console.WriteLine("Eneter number of files to upload"); int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { Console.WriteLine("Enter file path"); string filePath = Console.ReadLine(); Entry uploadFileEntry = dropbox.UploadFileAsync( new FileResource(filePath), "/" + newFolderName + "/" + Path.GetFileName(filePath).Trim()).Result; Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path); } DropboxLink sharedUrl = dropbox.GetShareableLinkAsync(createFolderEntry.Path).Result; Console.WriteLine(sharedUrl.Url); Process.Start(sharedUrl.Url); }
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); }