public string Create(TableInfo tableInfo, DrivePath path) { if (!AuthService.HasDriveAccess()) { throw new InsufficientPermissionException(); } tableInfo.Location = EstablishLocationForPath(new DrivePath(path)); GoogleFile file = CreateFile(GoogleFileTypes.GoogleSpreadsheet, tableInfo.Name, "id", tableInfo.Location, tableInfo.Description); SpreadsheetId = file.Id; tableInfo.Id = file.Id; return(file.Id); }
private string EstablishLocationForPath(DrivePath path) { string location = null; foreach (string folder in path) { string folderId = SearchFileId(GoogleFileTypes.Folder, folder, location); if (folderId != null) { location = folderId; } else { location = CreateFile(GoogleFileTypes.Folder, folder, "id", location).Id; Logger.Log($"Created folder named: {folder}, with id: {location}"); } } return(location); }