public string[] ReadDriveFolderForFiles(string folder = "In") { DriveService service = Authentication.AuthenticateOauth(GoogleClientId, GoogleClientSecret, GoogleUserName); string q = "title = '" + folder + "' and mimeType = 'application/vnd.google-apps.folder'"; var dir = GoogleDriveHelper.GetFiles(service, q); if (dir == null || dir.Count == 0) { return(null); } q = "'" + dir[0].Id + "' in parents"; var _filesInsideDir = GoogleDriveHelper.GetFiles(service, q); var retList = new List <string>(); foreach (var f in _filesInsideDir) { string downloadedFile = Path.Combine(DownloadLocation, f.OriginalFilename); GoogleDriveHelper.downloadFile(service, f.DownloadUrl, downloadedFile); if (System.IO.File.Exists(downloadedFile)) { retList.Add(downloadedFile); GoogleDriveHelper.removeFileFromFolder(service, dir[0].Id, f.Id); } } return(retList.ToArray()); }
public async Task <ActionResult> Index() { var service = await GoogleDriveHelper.AuthenticateServiceAccount("*****@*****.**", HttpRuntime.AppDomainAppPath + "Kia feed-69b23139ac76.p12"); var filePath = HttpRuntime.AppDomainAppPath + "Kia feeds.xlsx"; var file = await GoogleDriveHelper.UploadFile(service, filePath, ""); var files = await GoogleDriveHelper.GetFiles(service); return(View()); }