IEnumerator DownloadPoems() { int numFiles = 0; List <string> toDownload = new List <string>(); bool isDone = false; GoogleDriveFiles.List().Send().OnDone += list => { foreach (File file in list.Files) { if (!file.Name.Contains("virtualshackrecording")) { continue; } toDownload.Add(file.Id); numFiles++; } for (int i = 0; i < toDownload.Count; i++) { request = GoogleDriveFiles.DownloadAudio(toDownload[i], AudioType.WAV); request.Send().OnDone += file => { SavWav.Save("poem_" + i, file.AudioClip); slider.value = i; }; } isDone = true; }; while (!isDone) { yield return(null); } }
void CheckFilesExists() { // GoogleDriveRequest googleDriveRequest; // googleDriveRequest.Uri // getPath(); UnityGoogleDrive.GoogleDriveFiles.ListRequest list = GoogleDriveFiles.List(); list.Q = "name contains 'Saved_data'"; list.Send(); list.OnDone += GetResults; // yield return null; /* while (list.Progress < 1.0f && list.IsRunning) * { * Debug.Log(list.Progress); * } * * while (!list.IsDone && !list.IsError) * { * Debug.Log(list.Progress); * } * if (list.IsError) * { * * } * else if(list.IsDone) * { * Debug.Log(list.ResponseData); * } * UnityGoogleDrive.Data.ResourceData data; * data = list.GetResponseData<UnityGoogleDrive.Data.ResourceData>();*/ }
public IEnumerator Test002_FilesList() { var request = GoogleDriveFiles.List(); yield return(request.Send()); Assert.IsFalse(request.IsError); }
/// <summary> /// Looks for the files located at the provided path. /// </summary> /// <param name="path">File's path in Google Drive. Add front slash to find all files in a folder.</param> /// <param name="appData">Whether to use the AppData space instead of the drive root.</param> /// <param name="fields">Required fields for the list request. To request file's fields, use 'files(id, name, mimeType, ...)'.</param> /// <param name="mime">File's MIME type.</param> /// <param name="trashed">Whether to include trashed files.</param> public static async System.Threading.Tasks.Task <List <UnityGoogleDrive.Data.File> > FindFilesByPathAsync(string path, bool appData = false, List <string> fields = null, string mime = null, bool trashed = false) { var result = new List <UnityGoogleDrive.Data.File>(); var fileName = Path.GetFileName(path); var parentIds = await ValidatePath(path, appData); if (parentIds == null) { return(result); } var parentQueries = parentIds.Select(parentId => $"'{parentId}' in parents"); var query = $"({string.Join(" or ", parentQueries)}) and trashed = {trashed}"; if (!string.IsNullOrWhiteSpace(fileName)) { query += $" and name = '{fileName}'"; } if (!string.IsNullOrWhiteSpace(mime)) { query += $" and mimeType = '{mime}'"; } if (fields == null) { fields = new List <string>(); } fields.Add("nextPageToken, files(id)"); string pageToken = null; do { var listRequest = GoogleDriveFiles.List(query, fields, appData ? AppDataSpace : DriveSpace, pageToken); var fileList = await listRequest.Send(); if (fileList?.Files?.Count > 0) { result.AddRange(fileList.Files); } pageToken = fileList?.NextPageToken; listRequest.Dispose(); } while (pageToken != null); return(result); }
void DownloadFiles() { GoogleDriveFiles.List().Send().OnDone += list => { foreach (File listedFile in list.Files) { if (listedFile.Name.StartsWith("virtualshackrecording")) { GoogleDriveFiles.DownloadAudio(listedFile.Id, AudioType.WAV).Send().OnDone += file => { SavWav.Save("downloaded_" + listedFile.Name, file.AudioClip); }; } } }; }
private void ListFiles(string nextPageToken = null) { request = GoogleDriveFiles.List(); request.Fields = new List <string> { "nextPageToken, files(id, name, size, createdTime)" }; request.PageSize = ResultsPerPage; //if (!string.IsNullOrEmpty(query)) // request.Q = string.Format("name contains '{0}'", query); request.Q = string.Format("name contains '{0}' or name contains '{1}' or name contains '{2}'", ".png", ".jpg", ".jpeg"); if (!string.IsNullOrEmpty(nextPageToken)) { request.PageToken = nextPageToken; } request.Send().OnDone += BuildResults; }
void Update() { if (fileStatus == EDownloadStatus.kDownloadRequested) { fileStatus = EDownloadStatus.kInProgress; GoogleDriveFiles.List().Send().OnDone += RefreshFileList; } if (fileStatus == EDownloadStatus.kFilesListRefreshed) { fileStatus = EDownloadStatus.kInProgress; keyfile = files[0]; GoogleDriveFiles.Download(keyfile.Id).Send().OnDone += DownloadFile; } if (hasChanges && !(textForWalls is null) && fileStatus == EDownloadStatus.kDownloaded) { UpdateFile(); } }
private IEnumerator RestoreFromGoogleDriveSaveFileWithName(GameObject loadObject) { var request = GoogleDriveFiles.List(); yield return(request.Send()); string saveFileId = ""; for (int i = 0; i < request.ResponseData.Files.Count; i++) { if (request.ResponseData.Files[i].Name == "PS_SaveData") { saveFileId = request.ResponseData.Files[i].Id; break; } } if (saveFileId == "") { loadObject.SetActive(false); StopCoroutine(RestoreFromGoogleDriveSaveFileWithName(loadObject)); } var request2 = GoogleDriveFiles.Download(saveFileId); yield return(request2.Send()); string destination = Application.persistentDataPath + "/SaveData.xml"; File.Delete(destination); File.WriteAllBytes(destination, request2.ResponseData.Content); saveData = Load(); for (int i = 0; i < dataCreationManager.folderHolder.childCount; i++) { Destroy(dataCreationManager.folderHolder.GetChild(i).gameObject); } SetLoadedSaveData(); loadObject.SetActive(false); StructureManager.instance.NewNotification("Restore Completed"); }
public static int GetRecordingNum() { int maxNum = 0; GoogleDriveFiles.List().Send().OnDone += list => { foreach (File file in list.Files) { if (!file.Name.Contains("virtualshackrecording")) { continue; } string[] fileName = file.Name.Split('_'); int currentNum = FindIntInString(fileName[fileName.Length - 1]); if (currentNum >= myNum) { myNum = currentNum + 1; } } //Debug.Log(myNum); }; return(maxNum); }