public async Task <IReadOnlyCollection <ListedObject> > ExecuteAsync(ListObjectKeysCommand command, IReadOnlyCollection <ListedObject> previousResult) { Console.WriteLine($"Starting listing of prefix {command.Prefix}"); var listedObjects = new List <ListedObject>(); var listObjectsRequest = new ListObjectsV2Request { BucketName = _config.AmazonS3BucketName, Prefix = command.Prefix }; ListObjectsV2Response listObjectsResponse; do { listObjectsResponse = await _client.ListObjectsV2Async(listObjectsRequest); var newListedObjects = listObjectsResponse.S3Objects.Select(x => new ListedObject { Key = x.Key, LastModified = x.LastModified }); listedObjects.AddRange(newListedObjects); listObjectsRequest.ContinuationToken = listObjectsResponse.ContinuationToken; } while (listObjectsResponse.IsTruncated); Console.WriteLine($"Completed listing of prefix {command.Prefix}"); return(listedObjects); }
public Task <IReadOnlyCollection <ListedObject> > ExecuteAsync(ListObjectKeysCommand command, IReadOnlyCollection <ListedObject> previousResult) { var listedObjects = new List <ListedObject>(); foreach (var storedObject in _memoryObjectStore) { if (storedObject.Key.StartsWith(command.Prefix)) { listedObjects.Add(new ListedObject { Key = storedObject.Key, LastModified = storedObject.Value.LastModified }); } } return(Task.FromResult <IReadOnlyCollection <ListedObject> >(listedObjects)); }
public Task <IReadOnlyCollection <ListedObject> > ExecuteAsync(ListObjectKeysCommand command, IReadOnlyCollection <ListedObject> previousResult) { var listedObjects = new List <ListedObject>(); var pathToSearch = _config.RootFileObjectStore; if (pathToSearch.EndsWith(Path.DirectorySeparatorChar)) { pathToSearch = pathToSearch.Substring(0, pathToSearch.Length - 1); } var fileSystemEntries = _fs.Directory_GetFiles(pathToSearch, "*", SearchOption.AllDirectories); var fileSytemEntriesToList = new List <string>(); foreach (var fileSystemEntry in fileSystemEntries) { if (!_fileSystemEntriesToIgnoreRegexes.Any(x => x.Match(fileSystemEntry).Success)) { fileSytemEntriesToList.Add(fileSystemEntry); } } foreach (var filePath in fileSytemEntriesToList) { var relativePath = filePath.Replace($"{pathToSearch}{Path.DirectorySeparatorChar}", String.Empty); if (relativePath.StartsWith(command.Prefix)) { var fileSystemInfo = new FileInfo(filePath); listedObjects.Add(new ListedObject { Key = relativePath, LastModified = fileSystemInfo.LastWriteTimeUtc }); } } return(Task.FromResult <IReadOnlyCollection <ListedObject> >(listedObjects)); }