I am uploading files to FTP server using spring integration of FTP
@Bean
@ServiceActivator(inputChannel = "toFtpChannel")
public FtpMessageHandler handler() {
FtpMessageHandler handler = new FtpMessageHandler(ftpSessionFactory());
handler.setChmod(0600);
handler.setRemoteDirectoryExpression(new LiteralExpression("./Documents"));
return handler;
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = "toFtpChannel")
void sendToFtp(File file);
}
First, I tried to upload the files by setting the Chmod of the handler to 0600 but I get the below error.
java.lang.IllegalArgumentException: chmod operations not supported
Is there a way to upload the files and make them readable and writable. and also, do I need to create a file in my local Disk to upload it to the server or is there a way for me to create and edit a file directly in the Server?
答案 0 :(得分:1)
If you want to be able to read write directly on server using any ftp client like filezilla
:
You can change the ownership of the ftp folder to ftp user using the following command after sshing to your server using root:
chown -R ftpuser /var/www/html/uploadfolder/
here, ftpuser is just an example. You should use your own ftp user. You can level up and could give ownership in html directory too.
chown -R ftpuser /var/www/html/