REST API Put large data

I have a REST API implemented in microsoft Web API.
In my client i use HttpRequestMessage and HttpResponseMessage.
When i am sending a small class, I serialize it to JSON and then send it.
Soon, my class becomes bigger, and I need to JSON the class, zip it (in memory) and send to server. I can no longer use the same technique, I need to send the zip in chunks.

What is the proper way to achieve it ? I have read this post Posting a File and Associated Data to a RESTful WebService preferably as JSON

Need some good articles, I dont know where to start.


On the client side this should work pretty much out of the box...

        var httpClient = new HttpClient();

        httpClient.DefaultRequestHeaders.TransferEncodingChunked = true;

        var content = new CompressedContent(new StreamContent(new FileStream("c:big-json-file.json",FileMode.Open)),"UTF8");

        var response = httpClient.PostAsync("http://example.org/", content).Result;

You can find an implementation of CompressedContent in WebApiContrib. If you are using earlier than .net 4.5 the request will be buffered client side before sending. Unfortunately the underlying HttpWebRequest doesn't support buffered streaming until .net 4.5

链接地址: http://www.djcxy.com/p/48638.html

上一篇: 将文件和JSON数据发布到Spring休息服务

下一篇: REST API放大数据