public DropboxNoteUploader() { storage = new CloudStorage(); var dropboxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken; using (var fs = File.Open("DropBoxStorage.Token", FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = storage.DeserializeSecurityToken(fs); } storageToken = storage.Open(dropboxConfig, accessToken); InitNoteFolderIfNecessary(); }
public static CloudStorage OpenDropBoxStorage() { // Creating the cloudstorage object CloudStorage dropBoxStorage = new CloudStorage(); // get the configuration for dropbox var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); // declare an access token ICloudStorageAccessToken accessToken = null; // load a valid security token from file using (var tokenStream = new MemoryStream(SupportFiles.DropBoxToken)) { accessToken = dropBoxStorage.DeserializeSecurityToken(tokenStream); } // open the connection var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken); return dropBoxStorage; }
public NoteUpdater(string searchPattern = ".png") { SearchPattern = searchPattern; try { Storage = new CloudStorage(); var dropboxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken; using (var fs = File.Open(Properties.Settings.Default.DropboxTokenFile, FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = Storage.DeserializeSecurityToken(fs); } storageToken = Storage.Open(dropboxConfig, accessToken); InitFolderIfNecessary(); } catch (Exception ex) { Utilities.UtilitiesLib.LogError(ex); } existingNotes = new Dictionary<int, ICloudFileSystemEntry>(); }
internal static void LoadAccessToken() { string fileFullPath = Path.Combine(Environment.CurrentDirectory,Environment.UserName + "-Dropbox.tok"); if (File.Exists(fileFullPath)) { CloudStorage storage = new CloudStorage(); StreamReader tokenStream = new StreamReader(fileFullPath); config.DropboxAccessToken = storage.DeserializeSecurityToken(tokenStream.BaseStream); // close the cloud storage connection if (storage.IsOpened) { storage.Close(); } } }
public ActionResult GridViewPartialUpdate(inventarioImportaciones.Models.productos item) { var model = db.productos_List; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.Codigo == item.Codigo); if (item.Imagen.Length!=item.ImagenSelect.Length) { item.DirImagen = ""; string path = @"C:\Visual .net\DanielAsp"; string filename = path+"\\"+item.Nombre; var fsC = new BinaryWriter(new FileStream( filename + ".jpg", FileMode.Append, FileAccess.Write)); fsC.Write(item.ImagenSelect); fsC.Close(); CloudStorage dropBoxStorage = new CloudStorage(); var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken = null; // load a valid security token from file using (FileStream fs = System.IO.File.Open(@"C:\Visual .net\InventariosImportaciones\InventariosImportaciones\SharpDropBox.Token", FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = dropBoxStorage.DeserializeSecurityToken(fs); } var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken); var publicFolder = dropBoxStorage.GetFolder("/"); // GetFolder("/Public"); foreach (var fof in publicFolder) { // check if we have a directory Boolean bIsDirectory = fof is ICloudDirectoryEntry; // output the info Console.WriteLine("{0}: {1}", bIsDirectory ? "DIR" : "FIL", fof.Name); } String srcFile = Environment.ExpandEnvironmentVariables(filename + ".jpg"); ICloudFileSystemEntry fileUploaded= dropBoxStorage.UploadFile(srcFile, publicFolder); ICloudDirectoryEntry fEntry = dropBoxStorage.GetFolder("/"); ICloudFileSystemEntry fszz = dropBoxStorage.GetFileSystemObject("Gamma Quick Kids 21in.jpg", fEntry); string d = DropBoxStorageProviderTools.GetPublicObjectUrl(storageToken, fszz).AbsoluteUri; Console.WriteLine(d); dropBoxStorage.DownloadFile(publicFolder, item.Nombre + ".jpg", Environment.ExpandEnvironmentVariables(path)); dropBoxStorage.Close(); } if (modelItem != null) { this.UpdateModel(modelItem); db.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Please, correct all errors."; return PartialView("_GridViewPartial", model.ToList()); }
public void OpenConnection() { dropBoxStorage = new CloudStorage(); ICloudStorageAccessToken accessToken = null; // load a valid security token from file using (FileStream fs = File.Open(token_file_path, FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = dropBoxStorage.DeserializeSecurityToken(fs); } dropBoxStorage.Open(DropBoxConfiguration.GetStandardConfiguration(), accessToken); }
private void GetDropBoxAccess() { _dropBoxStorage = new CloudStorage(); var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken; using (var fs = File.Open("Accesstoken.txt", FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = _dropBoxStorage.DeserializeSecurityToken(fs); } _dropBoxStorage.Open(dropBoxConfig, accessToken); }