• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to change the permissions on a remote FTP Server ?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The FTPFile class has hasPermission and setPermission methods. You can get an array of FTPFile through the listFiles method in FTPClient.
 
Srinivas S
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic