Exception at ListAsync / FluentStorage.AWS.Blobs.Converter.ToBlobs
Hi,
With the latest version of FluentStorage, I got an exception with the ListAsync method.
<PackageReference Include="FluentStorage.AWS" Version="6.0.0" />
<PackageReference Include="FluentStorage" Version="6.0.0" />
This behavior does not occur in versions 5.5.0 and 5.6.0.
<PackageReference Include="FluentStorage.AWS" Version="5.5.0" />
<PackageReference Include="FluentStorage" Version="5.6.0" />
System.ArgumentNullException: The value cannot be null. (Parameter ‘source’)
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentStorage.AWS.Blobs.Converter.ToBlobs(ListObjectsV2Response response, ListOptions options)
at FluentStorage.AWS.Blobs.AwsS3DirectoryBrowser.ListFolderAsync(List`1 container, String path, ListOptions options, CancellationToken cancellationToken)
in FluentStorage.AWS.Blobs.AwsS3DirectoryBrowser.ListAsync(ListOptions options, CancellationToken cancellationToken)
in FluentStorage.AWS.Blobs.AwsS3BlobStorage.ListAsync(ListOptions options, CancellationToken cancellationToken)
If you need further information, just let me know.
BR
Could you download the source code of FluentStorage, add the project to your library, and see where the error is occurring at?
Basically to give any more details that help us fix it.
Same here. The only possible location is:
https://github.com/robinrodricks/FluentStorage/blob/9781afedee305e1c6a63c90d90b29a3d9b35418c/FluentStorage.AWS/Blobs/AwsS3DirectoryBrowser.cs#L60
Let me try applying a quick fix at that location
Could you try this https://www.nuget.org/packages/FluentStorage.AWS/6.0.1
Unfortunately, that doesn't work. I think the problem needs to be solved within the method.
From
public static IReadOnlyCollection<Blob> ToBlobs(this ListObjectsV2Response response, ListOptions options) {
var result = new List<Blob>();
//the files are listed as the S3Objects member, but they don't specifically contain folders,
//but even if they do, they need to be filtered out
result.AddRange(
response.S3Objects
.Where(b => !b.Key.EndsWith("/")) //check if this is "virtual folder" as S3 console creates them (rubbish)
.Select(b => b.ToBlob())
.Where(options.IsMatch)
.Where(b => options.BrowseFilter == null || options.BrowseFilter(b)));
//subfolders are listed in another field (what a funny name!)
//prefix is absolute too
result.AddRange(
response.CommonPrefixes
.Where(p => !StoragePath.IsRootPath(p))
.Select(p => new Blob(p, BlobItemKind.Folder)));
return result;
}
To
public static IReadOnlyCollection<Blob> ToBlobs(this ListObjectsV2Response response, ListOptions options) {
var result = new List<Blob>();
//the files are listed as the S3Objects member, but they don't specifically contain folders,
//but even if they do, they need to be filtered out
if(response.S3Objects != null && response.S3Objects.Count != 0)
{
result.AddRange(
response.S3Objects
.Where(b => !b.Key.EndsWith("/")) //check if this is "virtual folder" as S3 console creates them (rubbish)
.Select(b => b.ToBlob())
.Where(options.IsMatch)
.Where(b => options.BrowseFilter == null || options.BrowseFilter(b)));
}
//subfolders are listed in another field (what a funny name!)
if(response.CommonPrefixes!= null && response.CommonPrefixes.Count != 0)
{
//prefix is absolute too
result.AddRange(
response.CommonPrefixes
.Where(p => !StoragePath.IsRootPath(p))
.Select(p => new Blob(p, BlobItemKind.Folder)));
}
return result;
}
BR
Got the same error using MinIO, on ftp and sftp works, but on S3 doesn't