Esempio n. 1
0
        public static async Task <GoogleFileList> Get(GoogleDrive drive, GoogleFile folder, FileList fileList, DriveService service, CancellationToken token)
        {
            var ret = new GoogleFileList(drive);

            foreach (var googleFile in fileList.Items.Select(file => new GoogleFile(drive, file)))
            {
                if (googleFile.IsFolder)
                {
                    googleFile.hasChildren = await HasSubfoldersAsync(googleFile, service, token);
                }
                ret.files.Add(googleFile);
            }
            return(ret);
        }
Esempio n. 2
0
        private async Task <ICollection <DriveFile> > GetFilesAsync(DriveFile folder, string q, CancellationToken token)
        {
            try
            {
                var service = await GetServiceAsync(token);

                var request = service.Files.List();
                request.MaxResults = 1000;
                if (!string.IsNullOrWhiteSpace(q))
                {
                    q = string.Format("and ({0})", q);
                }
                request.Q      = string.Format("'{0}' in parents and trashed = false {1}", folder.Id, q);
                request.Fields = "items(downloadUrl,webContentLink,thumbnailLink,id,mimeType,createdDate,modifiedDate,fileSize,title,properties)";
                var files = await request.ExecuteAsync(token);

                return(await GoogleFileList.Get(this, (GoogleFile)folder, files, service, token));
            }
            catch (TokenResponseException ex)
            {
                throw new ConnectionException(Owner, ex.Message, ex);
            }
        }