Define path to save files in Linux

0

I have Back-end done in Java where I get some files from the front and save them to a folder. This system ran on a server Windows with Tomcat but recently it had to be migrated to Debian .

Previously I defined the path to save the files as follows:

D:\Auditoria\uploads\

Currently the path where I want to save these files is:

/opt/tomcat/modulos/auditoria/uploads

As I show in the image below

CanIgothatwaytosavemyfiles?Oristhereanotherway?

Icurrentlycreatemyarchivethisway:

privatefinalStringDIRETORIO_UPLOAD_ARQUIVO="D:\Desenvolvimento\Angular\Auditoria\uploads\anexos\";
File arquivo= new File(DIRETORIO_UPLOAD_ARQUIVO, file.getFileName());
    
asked by anonymous 11.08.2016 / 19:12

1 answer

1

DiegoAugusto is enough that you use the URL (path) of the destination directory. It is important to note that the tomcat execution user (tomcat daemon) must have execute permission in this directory.

One way to do this is to put the final directory as the group property of the tomcat user.

On my computer (virtualbox) tomcat is installed and run under the user tomcat7 and tomcat7 group.

Query the user name that is running tomcat (do this as root)

# ps -ef | grep tomcat

The answer will be something of the sort ....

tomcat7   4001     1  0 11:50 ?        00:00:03 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.....

This shows that tomcat is being run by tomcat7. It is this user that must have access permission in the directory that you want. To give permission, do (as root):

# chown -R tomcat7 /opt/tomcat/modulos/auditoria/uploads

I think this is enough to solve your problem.

t +

    
01.09.2016 / 17:01