FluentStorage icon indicating copy to clipboard operation
FluentStorage copied to clipboard

Inconsistent file path handling across storage providers

Open dtila opened this issue 1 year ago • 0 comments

First-time user, I gave a try to use the library for the app I am building. I am opening an issue to share my experience, code and I will make some suggestions.

I have used the library for native disk usage and with MinIO configuration, and the only operations were to ListAllFiles() and WriteAsync()

  1. First issue was when blob was configured to disk, the following code was throwing DirectoryNotFoundException return await _blobStorage.ListFilesAsync(new ListOptions { FilePrefix = path }, cancellationToken); the path variable had the value 100205175_3/. I fixed the issue by wrapping in a trycatch and returned an empty collection, like it was expected (despite that was provider specific exception). WriteAsync was called with filePaths like 100205175_3/00008_temp.pdf

  2. After had the code running perfectly with disk, I have configured to use MinIO. The write was successful since I could see the files in the bucket -> 100205175_3 (this was the folder name), all the files were there. I tried various inputs like 100205175_3/* , 100205175_3*, 100205175_3 or /100205175_3 but in every case an empty list was returned

I got the code and referenced it directly in my project to try to see if there is a quick issue, and I saw a lot of if's related to prefix and file paths. I haven't check other provider except Amazon, but I assume it's the same.

The challenge I see with this library is having uniform file paths and folder structure and this could be easily fixed by applying Domain Driven Design. That would require a full refactoring from the library but will fix all those issues and work like a charm.

I have a YouTube video where I am explaining how to build this: https://www.youtube.com/watch?v=6XfQxy0Js6I (ignore the persistence part). Since my YouTube is focused on content around DDD and how you apply in real-life projects, I may do a video with some refactoring to the project. However, this has to be agreed upon with the project maintainers as well.

Bottom line, due to the fact I was unable to find the issue, I have removed the library from my project and used the native MinIO library.

dtila avatar Oct 07 '24 09:10 dtila