I'm having a problem with paging---the paging interface is functional (i.e. you can click on buttons, and drag the handle on the bar) but no matter what page I'm on, I only see the first 100 files.
I verified that my GetFiles[] indeed returns the full list of several thousand files, but for some reason the list doesn't change when I page through.
Any idea where I can look to solve this problem?
public override DirectoryItem ResolveDirectory(string path)
{
path = CanonicalPathHelper.NormalizeDirectoryPath(path);
//Console.WriteLine("Looking at " + path);
FileItem[] filesResult = GetFiles(path);
// The directories will be added in the ResolveRootDirectoryAsTree method
// this seems to return the directory requested too.
return new DirectoryItem(GetDirectoryName(path),
string.Empty,
path,
path,
GetPermissions(path),
filesResult,
null);
}
private FileItem[] GetFiles(string path)
{
path = CanonicalPathHelper.NormalizeDirectoryPath(path);
List<FileItem> filesResult = new List<FileItem>();
try
{
var client = CreateS3Client();
Console.WriteLine("Checking Path " + path);
var request = ListBucketRequest(path);
int i = 0;
do
{
ListObjectsResponse response = client.ListObjects(request);
// Files
filesResult.AddRange(response.S3Objects.Where(x => IsFile(x.Key)).Select(
s3Obj =>
new FileItem(
s3Obj.Key,
VirtualPathUtility.GetExtension(s3Obj.Key),
s3Obj.Size,
string.Empty,
GetUrl(s3Obj.Key, true),
//string.Empty,
i++.ToString(),
GetPermissions(s3Obj.Key)
)
)
);
if (response.IsTruncated)
{
// next page of results
request.Marker = response.NextMarker;
}
else
{
request = null;
}
} while (request != null);
}
catch (AmazonS3Exception amazonS3Exception)
{
if (amazonS3Exception.ErrorCode != null &&
(amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId")
||
amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
{
Console.WriteLine("Check the provided AWS Credentials.");
}
else
{
Console.WriteLine(
"Error occurred. Message:'{0}'",
amazonS3Exception.Message);
}
return null;
}
return filesResult.ToArray();
}