I'm working with .net to provide REST api for my app. I'm trying to do the following: import some big bunch of data from client side from csv file (~100K records) and process it on the server. Since processing can take some time I would like to provide user with percentage of the task completion. The question is how to do it using post request which uploaded the file without closing the connection?
我正在使用.net为我的应用程序提供REST api。我正在尝试执行以下操作:从客户端从csv文件(~100K记录)导入一大堆数据并在服务器上处理它。由于处理可能需要一些时间,我想为用户提供任务完成的百分比。问题是如何使用上传文件的帖子请求而不关闭连接?
Is that possible to send several responses before sending complete?
发送完成之前是否可以发送多个响应?
Due to requirements I can't use such things as websockets, only REST api. I guess that I can do something like longpolling or just make small requests for the percentage with some time interval, but it would be nice to find some simplier alternative solution for that.
由于要求我不能使用websockets这样的东西,只能使用REST api。我想我可以做一些像longpolling这样的事情或只是用一些时间间隔对百分比做出小的请求,但是找到一些更简单的替代解决方案会更好。
1 个解决方案
#1
0
You can use some kind of Pubnub to do that. You can send to server your csv file and some unique id of channel name. Subscribe to this channel on client and you can publish from server messages about the task progress to this unique id name (channel). Read this documentation: pubnub
你可以使用某种Pubnub来做到这一点。您可以向服务器发送您的csv文件和一些唯一的通道名称ID。在客户端上订阅此频道,您可以从服务器上将有关任务进度的消息发布到此唯一ID名称(频道)。阅读本文档:pubnub
#1
0
You can use some kind of Pubnub to do that. You can send to server your csv file and some unique id of channel name. Subscribe to this channel on client and you can publish from server messages about the task progress to this unique id name (channel). Read this documentation: pubnub
你可以使用某种Pubnub来做到这一点。您可以向服务器发送您的csv文件和一些唯一的通道名称ID。在客户端上订阅此频道,您可以从服务器上将有关任务进度的消息发布到此唯一ID名称(频道)。阅读本文档:pubnub