In my Spring Roo application, I upload some files to the local VMware vFabric tc server on the Spring source tool (STS) platform. When a user uploads some files through the application, he is loaded by default on the STS IDE path (in my case C:\Program Files\springsource\sts-2.8.1.RELEASE\tempDir) , but it must be loaded on the server. I have the following code in my object to save a file:
public void setFile(CommonsMultipartFile file) { this.file = file; this.size = file.getSize(); int dotPos = tempFileName.lastIndexOf("."); String extension = file.getOriginalFilename().substring(dotPos + 1); this.fileName = new Date().getTime() + "." + extension; File outputFile = new File(pathToSave + fileName); if (outputFile == null || !outputFile.exists()) { new File(pathToSave).mkdirs(); } try { file.transferTo(outputFile); } catch (IllegalStateException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } }
How can I upload files to the server instead of the IDE path?
source share