问题描述
我工作的Apache的FTP服务器整合到我的Android应用程序。结果
按照这里的指令(嵌入的FTPServer在5分钟内):。
I am working on integrating Apache FTP server to my Android app.
Follow the instructions here ( Embedding FtpServer in 5 minutes): http://mina.apache.org/ftpserver-project/embedding_ftpserver.html.
然而,与所有的$ C $包括CS和进口到我的Android项目的jar文件,我得到了两大错误:
1.在FTP服务器程序崩溃的开始声称未找到类
2. Dalvik的错误1
However, with all the codes included and the jar files imported to my android project, I got two major errors:1. App crash upon ftp server start claiming class not found2. Dalvik error 1
通过研究所有相关的问题,想尽一切方法和解决办法是保持指令,该指令中列出(嵌入的FTPServer在5分钟内)的jar文件的小子集,使code编译。由于不会有太多的JAR文件,这样我只是做了一些尝试和错误,让我的小子集。
Tried every method by researching all related problems and the solution is to keep the minimal subset of the jar files that are listed in the (Embedding FtpServer in 5 minutes) instruction and make the code compile. Since there are not many jar files so I just did some try and error to get my minimal subset.
在我使用了一些新的code键启动FTP服务器(这里是链接)的
After that I use some new code to start the ftp server(here is the link): writing a java ftp server
不过,我无法连接,因为它说缺少user.properties文件。我下载的FTPServer-1.0.6-src源$ C $ C,把user.properties文件到我的Android SD卡,使FTP开始。我把在资产user.properties文件夹,然后再通过使用一些code将其复制到SD卡。
However I couldn't connect because it says missing user.properties file. I download ftpserver-1.0.6-src source code and put the user.properties file into my android sdcard to make the ftp start. I put the user.properties file in the assets folder first, then copy it to the sdcard by using some code.
现在一切似乎工作。不过,我不能够使用匿名登陆我的用户名和密码,使用设置:
BaseUser用户=新BaseUser();
user.setName(测试);
user.setPassword(测试);
Now everything seems to work. However, I am not able to use anonymous login as my user name and password is set using: BaseUser user = new BaseUser(); user.setName("test"); user.setPassword("test");
如果我没有设置它,在code将无法编译。结果
注册为匿名用户是最后一部分,我必须做的。
另一件小事是,当我ftp到我的Android服务器,它不会让我下载的文件,因为它没有返回权限错误。
If I don't set it, the code won't compile.
Log in as anonymous user is the last part I have to do.Another trivial thing is when I ftp to my android server, it won't allow me to download the files as it returns no permission error.
任何建议都欢迎。谢谢
推荐答案
我也有同样的问题,所以我创建我的自定义新的users.properties文件。
这是code:
I've have had the same problem, so I've created my custom new users.properties file.Here it is the code:
File files=new File(filepath + "/users.properties");
if (!files.exists()) {
try {
files.createNewFile();
} catch (IOException e) {
Log.e(TAG, "Errore nella creazione del file di log", e);
e.printStackTrace();
}
}
userManagerFactory.setFile(files);
userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
UserManager um = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("xxx");
user.setPassword("yyy");
user.setHomeDirectory("/mnt/sdcard");
List<Authority> auths = new ArrayList<Authority>();
Authority auth = new WritePermission();
auths.add(auth);
user.setAuthorities(auths);
try {
um.save(user);
} catch (FtpException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
这篇关于与Android Apache的FTP服务器整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!