2020IP / TwentyTwenty.Storage

A cross-cloud storage abstraction
Other
100 stars 26 forks source link

AWS ListBlobsAsync trims first letter of object key when listing root of bucket #43

Open DanielHarman opened 1 year ago

DanielHarman commented 1 year ago

I'm currently trying to list files that are just contained in the root of a bucket in S3.

var listBlobsAsync = await _storageProvider.ListBlobsAsync("");

I expect to get a list of BlobDescriptors with the keys file1.txt, file2.txt and file3.txt for example but instead get ile1.txt, ile2.txt and ile3.txt

The problem occurs here because even when an empty string is provided, it will always trim at least one character.

https://github.com/2020IP/TwentyTwenty.Storage/blob/2cceedeb1fdf9c05105359363e5a2209d6eb601c/src/TwentyTwenty.Storage.Amazon/AmazonStorageProvider.cs#L380

splitice commented 1 year ago

That method can also crash I've found.

Unhandled exception: System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. (Parameter 'count')
   at System.String.Remove(Int32 startIndex, Int32 count)
   at TwentyTwenty.Storage.Amazon.AmazonStorageProvider.ListBlobsAsync(String containerName)
   at X4BFlow.Main.DbLink.ObjConnector.ListBlobs(String containerName)+MoveNext() in /home/runner/work/X4BFlow.Net/X4BFlow.Net/X4BFlow.Main/DbLink/ObjConnector.cs:line 36

I havent yet worked out what the cause is though