问题
I am sending data for up to 10K users in JSON format to a http endpoint in a .NET Core MVC server app. The JSON is built slowly user by user and is custom (JSON.NET just isn't usable for me). I use a HttpClient and I basically want to send the JSON chunk by chunk so I don't have to accumulate it all at once and sit with a multi-megabyte string in memory for each request, hurting my large object heap. I cannot find and equivalent for HttpWebRequest.GetRequestStream that was used earlier.
StreamContent doesn't seem to fit the bill, I even found PushStreamContent, PipeStream etc. but I don't see a way how to do it, haven't found any answers on SO... Last option I can think of seems to inherit from Stream and implement it myself, but there must be a better way, many people must've encountered this problem.
Any advice?
来源:https://stackoverflow.com/questions/57727883/chunked-large-json-post-using-net-httpclient