public override void Cancel() { base.Cancel(); if (downloadRequest != null) { downloadRequest.Abort(); downloadRequest = null; } }
private async UniTask <byte[]> ExportFileAsync(UnityGoogleDrive.Data.File fileMeta) { Debug.Assert(converter is IGoogleDriveConverter <TResource>); var gDriveConverter = converter as IGoogleDriveConverter <TResource>; downloadRequest = new GoogleDriveFiles.ExportRequest(fileMeta.Id, gDriveConverter?.ExportMimeType); await downloadRequest.SendNonGeneric(); if (downloadRequest.IsError || downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content == null) { throw new Exception($"Failed to export '{Path}' resource from Google Drive."); } return(downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content); }
private async UniTask <byte[]> DownloadFileAsync(UnityGoogleDrive.Data.File fileMeta) { if (useNativeRequests) { if (typeof(TResource) == typeof(AudioClip)) { downloadRequest = GoogleDriveFiles.DownloadAudio(fileMeta.Id, WebUtils.EvaluateAudioTypeFromMime(fileMeta.MimeType)); } else if (typeof(TResource) == typeof(Texture2D)) { downloadRequest = GoogleDriveFiles.DownloadTexture(fileMeta.Id, true); } } else { downloadRequest = new GoogleDriveFiles.DownloadRequest(fileMeta); } await downloadRequest.SendNonGeneric(); if (downloadRequest.IsError || downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content == null) { Debug.LogError($"Failed to download {Path}{usedRepresentation.Extension} resource from Google Drive."); return(null); } if (useNativeRequests) { if (typeof(TResource) == typeof(AudioClip)) { loadedObject = downloadRequest.GetResponseData <UnityGoogleDrive.Data.AudioFile>().AudioClip as TResource; } else if (typeof(TResource) == typeof(Texture2D)) { loadedObject = downloadRequest.GetResponseData <UnityGoogleDrive.Data.TextureFile>().Texture as TResource; } } return(downloadRequest.GetResponseData <UnityGoogleDrive.Data.File>().Content); }