发放的允许一个FTP文件的java [英] Giving permission to a ftp FILE java
本文介绍了发放的允许一个FTP文件的java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在android的一类与FTP连接和存储的图像,即可以完美运行的问题是,当我试图将图像移动到另一个目录(我用一个PHP页面来主持的图片)它不有权处理它,我希望把权限为0777,但只有Java的code可以做到这一点,但我不知道怎么了,
我使用FTPClient库
这是我的code
文件镜像文件=新的文件(URL [0]); FTPClient ftpClient =新FTPClient(); ftpClient.connect(InetAddress.getByName(MYSERVER));
ftpClient.login(登录,通行证); ftpClient.changeWorkingDirectory(目录);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
的BufferedInputStream buffIn = NULL;
buffIn =新的BufferedInputStream(新的FileInputStream(镜像文件));
ftpClient.enterLocalPassiveMode();
ftpClient.storeFile(URL [1] +,buffInJPG);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();
解决方案
我被命令做它
ftpClient.storeFile(URL [1] +,buffInJPG);
一个布尔值= ftpClient.sendSiteCommand(文件模式+777+/absolutepath/\"+url[1]+\".jpg);
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();
解决方案
I made it by command
ftpClient.storeFile(url[1]+".jpg", buffIn);
boolean a = ftpClient.sendSiteCommand("chmod " + "777 " + "/absolutepath/"+url[1]+".jpg");
这篇关于发放的允许一个FTP文件的java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文