简体   繁体   中英

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. The other is a web server that provides an interface for users to interact with the service. One requirement is the ability to upload AND download files >100MB (but might as well be any size). 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. 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. Is there a more obvious and simple choice for sending a large file between two servers with 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? 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

<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://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch16s08.html

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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