-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[C#] Stream file uploads instead of copy all bytes into memory #2819
Comments
@hacki11 thanks for the suggestion. Do you have cycle to submit a PR with the suggested change? Ref: https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md |
Unfortunately, RestSharp 105.1.0 loads the complete body into memory before send. |
@hacki11 are you referring to this issue? restsharp/RestSharp#814 Roughly how large is your file? |
@wing328 i did not know there is already an issue - nice investigation! it can easily grow to several hundred MB to 1 GB. |
i compiled the RestSharp master and the EOF Error on server side due to missing Content-Length is fixed now. |
If you perform a debug, did you hit the following line mentioned in the SO comment? |
yes, I hit that line and it uses the Action of the FileParameter Writer Property. |
@hacki11 I would suggest 2 things:
|
It looks like RestSharp supports file streaming via WriteMultipartFormData. You'd have to set
|
@hacki11 did you have a chance to review the feedback from @jimschubert and give it a try? |
@hacki11 thanks for your investigation work. Looks like you'd get the exception on that line because ParameterToFile is flushing the stream. Do you have a test project repo you used for investigation, or were you testing against your codebase? |
Seems to be related to this restsharp/RestSharp#889 |
@chenzhekl thanks for the pointer. You may be interested in this task as well: #7012 |
Don't use |
ApiClient::ParameterToFile will copy complete file into ram before upload to rest service.
what about streaming a file to avoid OutOfMemory Exceptions on large files like:
current implementation:
ApiClient.mustache
The text was updated successfully, but these errors were encountered: