Search code examples
javaapache-commons-net

How can I change permissions of a file on a ftp server using apache commons net ftp?


If have a list of ftp files from a server, how can I change the permission on one of these files?

If someone can point me to a tutorial or show me an example I would be grateful. I have figured out how to change the permission in the file but not how to make the change permanent on the server.

Any suggestions?


Solution

  • Setting the permission of a file can be achieved by using this in the directory where the file or directory is:

    ftpClient.sendSiteCommand("chmod " + "755" + " example.html");
    

    NOTE: Why no one knows how setPermission() in FTPFile works is a mystery to me. Because it seems like a better way instead of using command line for setting permission of a ftpFile in apache commons net library!