Skip to content
Stefan Vigerske edited this page Mar 5, 2019 · 1 revision

Uploading Large Files

The default way to upload a file for solution on a remote server is to use Web services. However, for large files (say over 30 megabytes) this may not be efficient. One reason is that in creating the SOAP evelope each "<" or ">" in the instance is replaced by four characters, < or >. Furthermore, software such as Apache Axis may have trouble with large files.

A simple solution is to use the HTTP POST method with enctype="multipart/form-data". In our implementation we use a Java Servlet to handle the POST request, but any similar technology can be used.

In the examples folder this is illustrated with the fileUpload example. See the code fileUpload.cpp This main routine takes exactly one argument which is the location of the file on the local/client machine.

OSSolverAgent* osagent = NULL;
osagent = new OSSolverAgent("http://***.***.***.***:8080/fileupload/servlet/OSFileUpload");
uploadResult = osagent->fileUpload(osilFileName, osil);

creates the OSSolverAgent that uploads the file named osilFileName. We then create a new OSSolverAgent and solve the problem on the remote server using the COIN-OR Cbc package.

osagent = new OSSolverAgent("http://128.135.130.17:8080/cbc/CBCSolverService.jws");
std::string osrl = osagent->solve("", osol);

The osol option intance tells the remote solver that the instance is actually on the solver server. This osol is

"<osol>
   <general>
      <instanceLocation locationType=\"local\">" + remoteFileLocation + osilFileName + "</instanceLocation>
   </general> 
</osol>"