private void connectToolStripMenuItem_Click(object sender, EventArgs e) { var d = new FrameConnect(); if (d.ShowDialog() == DialogResult.OK) { cloudType = d.type; if (cloudType == CloudTypeEnum.AWS) { // TODO aws = new AwsDataModel(); } else if (cloudType == CloudTypeEnum.GCP) { try { gcp = new GcpDataModel(); gcp.credentialsFilePath = d.gcpCredsPath; gcp.projectId = d.gcpProjectId; var creds = GoogleCredential.FromFile(gcp.credentialsFilePath); gcp.client = StorageClient.Create(creds); } catch (Exception ex) { MessageBox.Show(ex.Message); } fs = CloudFileSystemIngestor.IngestGcp(gcp); currentDirectoryNode = fs.GetRootNode(); loadListFilesAtDirPath(currentDirectoryNode.AbsolutePath); } } }
public static CloudFileSystem IngestGcp(GcpDataModel gcp) { var fs = new CloudFileSystem(); var buckets = gcp.client.ListBuckets(gcp.projectId); foreach (var bucket in buckets) { var root = fs.GetRootNode(); var child = new CloudFileSystemNode { Name = bucket.Name, AbsolutePath = String.Format("{0}{1}", root.AbsolutePath, bucket.Name), Type = CloudFileSystemNodeTypeEnum.BUCKET }; fs.AddChild(root, child); foreach (var file in gcp.client.ListObjects(child.Name)) { var path = String.Format("cloud://{0}/{1}", bucket.Name, file.Name); fs.AddFileWithAbsolutePath(path); } } return(fs); }
public static string GetParentDirectoryPath(string path) { if (!String.IsNullOrEmpty(path)) { path = CloudFileSystem.RemovePrefix(path); var pos = path.LastIndexOf("/"); if (pos > -1 && path.Length > 0) { path = path.Substring(0, pos); } else { path = ""; } } path = AddPrefix(path); return(path); }
private void toolStripButtonUp_Click(object sender, EventArgs e) { var path = CloudFileSystem.GetParentDirectoryPath(currentDirectoryNode.AbsolutePath); loadListFilesAtDirPath(path); }