简体   繁体   English

使用Spring在两台服务器之间发送大文件的最简单方法?

[英]Simplest way of sending a large file between two servers with Spring?

I'm building two applications that interact with each other. 我正在构建两个相互交互的应用程序。 One is a web service running on either a Windows or Unix machine that has methods available to perform various actions on files. 一种是在Windows或Unix机器上运行的Web服务,该服务具有可用于对文件执行各种操作的方法。 The other is a web server that provides an interface for users to interact with the service. 另一个是Web服务器,为用户提供与服务交互的界面。 One requirement is the ability to upload AND download files >100MB (but might as well be any size). 一个要求是能够上传和下载大于100MB的文件(但也可以是任何大小)。 I've been trying to make it work by putting the file's bytes into a SOAP request like I have with all the other services but I keep getting OutOfMemory errors with larger files. 我一直试图通过将文件的字节放入SOAP请求中来使其工作,就像我使用所有其他服务一样,但是对于较大的文件,我始终会遇到OutOfMemory错误。 I've tried using Axiom and JAXB with MTOM enabled to try and stream the bytes but going by the Spring MTOM sample ( particularly this part ), it seems like you have to really get into some nasty code to get it working correctly. 我已经尝试使用启用了MTOM的Axiom和JAXB尝试流传输字节,但是在Spring MTOM示例( 尤其是这一部分 )看来,您似乎必须深入一些讨厌的代码才能使其正常工作。 Is there a more obvious and simple choice for sending a large file between two servers with Spring? 使用Spring在两个服务器之间发送大文件是否有更明显,更简单的选择?

As a side-question, is there an eaiser way of sending a file upload request object created with JAXB to where you don't have to write as much code as in the MTOM sample above? 作为附带的问题,是否有一种简便的方法可以将用JAXB创建的文件上传请求对象发送到不必编写上面MTOM示例中那么多代码的地方? Something as simple as: 像这样简单:

StoreFileRequest request = new StoreFileRequest();
request.setDestination(destination);
request.setFileData(dataHandler);
getWebServiceTemplate().marshalSendAndReceive(request)

Thanks for any ideas! 感谢您的任何想法!

Use apache fileupload even Spring websites links to it 使用apache fileupload甚至Spring网站链接到它

<form method="POST" enctype="multipart/form-data" action="fup.cgi">
  File to upload: <input type="file" name="upfile"><br/>
  Notes about the file: <input type="text" name="note"><br/>
  <br/>
  <input type="submit" value="Press"> to upload the file!
</form>

Note: each browser has it's own max size:take a look at the first link below. 注意:每个浏览器都有自己的最大大小:请看下面的第一个链接。

http://www.motobit.com/help/scptutl/pa98.htm http://www.motobit.com/help/scptutl/pa98.htm

http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch16s08.html http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch16s08.html

http://commons.apache.org/proper/commons-fileupload/ http://commons.apache.org/proper/commons-fileupload/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM