File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Java Products and Servers and the fly likes How to change the permissions on a remote FTP Server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "How to change the permissions on a remote FTP Server ?" Watch "How to change the permissions on a remote FTP Server ?" New topic
Author

How to change the permissions on a remote FTP Server ?

Srinivas S
Greenhorn

Joined: Nov 09, 2005
Posts: 2
Hi All,

I am using org.apache.commons.net.ftp.* package for my FTP related activities in my code.

I want to store a file in the remote FTP server with write permission set to the file so that file can be overwritten by any one.

I am using storeFile(String rem,InputStream local) API to store the file in the remote server.But by default this API is storing the File on remote FTP server with "-rw-r--r--" permission .

Is there a way that I can change the permission bits for this file on the remote FTP server to make it writeable by anyone? If not can I set some properties before the call to storeFile() API so that the file is stored with required permissions set ?

Any help in this regard is highly Appreciated.

Thanks,
Srini


storeFile(String rem,InputStream local);
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
The FTPFile class has hasPermission and setPermission methods. You can get an array of FTPFile through the listFiles method in FTPClient.


Ping & DNS - my free Android networking tools app
Srinivas S
Greenhorn

Joined: Nov 09, 2005
Posts: 2
Ulf,

Thanks for your reply, I tried to use these API's to set the file permission but not with much success.I am using the below code snapshot below to change the permission. I am able to set the permissions for the FTPFile objects in the FTPFile[] arrayList below.But this file permission change is not getting reflected to the file in the remote FTP server, Is there an API where I can store this FTPFile object with the modified file permission directly to the remote FTP server ?

FTPFile[] files=ftp.listFiles(ftpFileName);
for(int ii=0;ii<files.length;ii++){
for(int access=0;access<3;access++){
files[ii].setPermission(access,files[ii].READ_PERMISSION,true);
files[ii].setPermission(access,files[ii].WRITE_PERMISSION,true);
}
}


I have used storeFile(String remote, InputStream local) API to store a file remotely.But couldn't find any API's which can store the FTPFile object to the remote server.

Thanks,
Srini
Devashish Patyal
Greenhorn

Joined: Jun 12, 2013
Posts: 1
Srinivas S wrote:Ulf,

Thanks for your reply, I tried to use these API's to set the file permission but not with much success.I am using the below code snapshot below to change the permission. I am able to set the permissions for the FTPFile objects in the FTPFile[] arrayList below.But this file permission change is not getting reflected to the file in the remote FTP server, Is there an API where I can store this FTPFile object with the modified file permission directly to the remote FTP server ?

FTPFile[] files=ftp.listFiles(ftpFileName);
for(int ii=0;ii<files.length;ii++){
for(int access=0;access<3;access++){
files[ii].setPermission(access,files[ii].READ_PERMISSION,true);
files[ii].setPermission(access,files[ii].WRITE_PERMISSION,true);
}
}


I have used storeFile(String remote, InputStream local) API to store a file remotely.But couldn't find any API's which can store the FTPFile object to the remote server.

Thanks,
Srini







any success on this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change the permissions on a remote FTP Server ?