AngularJS compress $http post data

馋奶兔 提交于 2019-12-04 03:29:47

问题


I'm creating an Ionic app that needs to send big amounts of data to a server written in php. I'm looking for a way to compress the data I post to speed up my app. I'm not sure of what's the best approach, I tried LZString but the compressToEncodedURIComponent return value size is too big for my needs, I then tried using pako but I still wasn't satisfied with the compression rate. Which is the best way to compress the data I post to the server? Should I compress it separately(with one of the libraries I mentioned) or is there a way to let the Angular $http service handle the compression?


回答1:


Angular has no compression utilities.

If you really need to compress then you will have to find a JavaScript library to do so, which I know nothing about, but this question and this question would be good places to start.

Given that compression can take some time itself (and doesn't always yield great results), perhaps another alternative is to make the data as lean as possible using your own code, then just have a good 'waiting' UX - keep the user informed about the progress and let them do stuff while it uploads in the background. Most mobile users will expect large data transfers to take a while anyway.



来源:https://stackoverflow.com/questions/32246690/angularjs-compress-http-post-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!