Spring Roo Application File Download Path

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?

+4
source share
1 answer

Tomcat can be configured to use any directory (write access to it) to upload files (see Configuring Tomcat to use a different temp directory to upload files to ServerFault).

Since VMware vFabric tc server comes bundled with STS, it is probably preconfigured to use a temporary IDE directory. This technically still on the server because you are working on localhost

0
source

Source: https://habr.com/ru/post/1388384/


All Articles