Decouple file-access logic
opened this issue · comments
Hello there,
I wanted to implement a simple progress-tracking and noticed that the logic to read the file, and write it to the request-stream is implemented several times, slightly differently, violating e.g. DRY or SoC.
If you agree that this is a problem, how would you solve it?
My proposals:
- A) Defining an interface like
IFileDataProvider
with a simple signature likeWriteFileToStream(string path, Stream requestStream)
- B) A parameter like
Action<string, Stream, long> streamWriter
I see the following advantages of this approach:
- Removes redundancy
- Ensures SoC
- Great flexibility: You don`t care if the file to upload is on your local computer, or a remote http resource