Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple file-access logic #43

Open
3 tasks done
ghost opened this issue Apr 3, 2017 · 0 comments
Open
3 tasks done

Decouple file-access logic #43

ghost opened this issue Apr 3, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 3, 2017

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.

  1. In the MultiPartStreamer class (here)
  2. In the HttpRequest class (here).

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 like WriteFileToStream(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants