-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Multi-file request support #109
base: master
Are you sure you want to change the base?
Conversation
Update ToHttpContent helper function to copy files to MemoryStreams to prevent InvalidOperationException from occuring when multiple files are sent in a request
Hey, sorry for the delay. Can you add a passing / failing test that exercise this case, and the counter case? |
Hi @dotfortun3-code, I cannot repro this issue in the test. I have added more files to the |
try to create an api with a multiform/form-data body in post, that accepts a IFormFileCollection in the body. You'll see instantly the problem. |
Ok, cool. I will try to get to this. If possible, it would be extremely helpful if you could add the test that would have failed, but is fixed by this PR, so that it remains covered. |
I can probably take a look at adding the test soon-ish. I just had a baby a few weeks ago so I've been a little tied up haha! |
Woohoo! Congrats! |
Congratulations!!! The problem is that the test passes, but in real cases the api gives back 200, but the files are not uploaded in the folder, so maybe this should be checked in the test. I've tried it but not succeeded. |
@dotfortun3-code Congrats! I notice that the fix doesn't work with text/csv files. It seems like it doesn't read the file content. I fixed this by setting the position of the Memory Stream to the beginnig before creating the Stream Content:
|
When uploading multiple files, an InvalidOperationException would occur when the request is forwarded. Copying the content to a MemoryStream first stops the exception from occurring.
Updated ToHttpContent helper function to copy files to a MemoryStream to prevent InvalidOperationException from occuring when multiple files are sent.