How to limit an upload speed in java servlet?

谁说我不能喝 提交于 2019-12-08 05:45:46

问题


I'm working on an app (based on Spring as DI and MVC framework) that has a file upload function which is currently implemented using Spring Multipart Upload (which in it's turn utilizes commons fileupload libs).

So what I'm looking for is a way to lower the upload bandwidth consumption. How can I accomplish that?


回答1:


Limiting the upload bandwidth consumption may not be possible unless you are using a custom file uploader on the client. Assuming that the Spring Multipart Upload is just an interface to the standard HTTP multipart form upload then it's the client web browser that implements the actual streaming of the file from the client to the server. Unless the client's browser has some functionality to limit the bandwidth it's probably trying it's best to get it uploaded as quickly as possible.




回答2:


May be this one here helps : Multipart Post method example




回答3:


I think this completely depends on the network bandwidth, this doesnot have any dependency with the Servlet programming.

Only the size of the uplaoding file might be a problem in some matters, else Every thing should be working fine




回答4:


I'm wondering if you could use the streaming API from Commons FileUpload instead of the standard API, and throttle the bandwidth that way.



来源:https://stackoverflow.com/questions/2738706/how-to-limit-an-upload-speed-in-java-servlet

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