Reputation: 2615
i have a class in android that connect with the ftp, and store an image, that works perfect the problem is when i am trying to move the image to another directory( i use a php page to moderate that image) it doesnt have permission to handle it, i want to put the permission to 0777 but only the "java code" can do it but i dont know how,
I am using FTPClient library
this is my code
File imageFile = new File(url[0]);
FTPClient ftpClient = new FTPClient(); ftpClient.connect(InetAddress.getByName("myserver"));
ftpClient.login("login", "pass");
ftpClient.changeWorkingDirectory("directory");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
BufferedInputStream buffIn=null;
buffIn=new BufferedInputStream(new FileInputStream(imageFile));
ftpClient.enterLocalPassiveMode();
ftpClient.storeFile(url[1]+".jpg", buffIn);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();
Upvotes: 0
Views: 3731
Reputation: 2615
I made it by command
ftpClient.storeFile(url[1]+".jpg", buffIn);
boolean a = ftpClient.sendSiteCommand("chmod " + "777 " + "/absolutepath/"+url[1]+".jpg");
Upvotes: 1
Reputation: 2563
See the FTPClient and FTPFile API You can do something like that :
...
ftpClient.storeFile(url[1]+".jpg", buffIn);
FTPFile file = ftpClient.mlistFile(url[1]+".jpg");
file.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION, true);
file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
...
Upvotes: 1