I am using AWS SDk for .NET, I am trying to get the directory info from an S3 bucket.
The following code works and I can get the files in my root folder
// path: folder
S3DirectoryInfo di = new S3DirectoryInfo(s3Client, "myS3BucketName", "folder");
if (di.Exists)
{
IS3FileSystemInfo[] files = di.GetFileSystemInfos();
}
Now I try the same code, and query a sub-folder
under folder
, the code gets the directory info... but while reading the file contents, it throws exception
// path: folder/sub-folder
S3DirectoryInfo di = new S3DirectoryInfo(s3Client, "myS3BucketName", "folder/sub-folder");
if (di.Exists)
{
// directory exists, but reading files throws exception
IS3FileSystemInfo[] files = di.GetFileSystemInfos();
}
This is the exception:
Key is a directory
This is how I initialize the s3Client:
s3Client = new AmazonS3Client("Ak...access-key...", "+8b...secret-key...", RegionEndpoint.APSoutheast2);