FTPClient corrupts the images while uploading to ftp server on android?(FTPClient 在上传到 android 上的 ftp 服务器时损坏图像?)
问题描述
我正在尝试从 Android 手机 (HTC Desire HD) 将图像上传到 FTP 服务器(在我的本地 PC 上).图像将发送到 FTP 服务器,但它们已损坏.
I'm trying to upload images to a FTP server (on my local PC) from Android Phone (HTC Desire HD). Images are going to FTP server but they are corrupted.
并且方法(ftpClient.storeFile())抛出IOException(Bad File Number)
请帮帮我.
这是损坏的图片链接:
http://imageshack.us/photo/my-images/820/komikb.jpg/
这是代码:
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect("192.168.2.14");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
ftpClient.setSoTimeout(10000);
ftpClient.enterLocalPassiveMode();
if(ftpClient.login("Administrator", "xxxx"))
{
File sFile=new File("mnt/sdcard/DCIM/komik.jpg");
FileInputStream fs= new FileInputStream(sFile);
String fileName = sFile.getName();
Boolean result = ftpClient.storeFile("/ftpfile.atspace.co.uk/" + fileName, fs);
String has = "";
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
推荐答案
问题解决了.FTPClient 类有最后一个数据包数据丢失错误".但这已通过 3.0.1 23.05.2011 版本解决.
Problem is solved. FTPClient class has "last packet data loss bug". But this was solved with 3.0.1 23.05.2011 release.
你可以从关于bug的详细解释中看到:https://issues.apache.org/jira/browse/NET-409
You can see from detailed explanation about bug: https://issues.apache.org/jira/browse/NET-409
您可以下载固定版本https://repository.apache.org/content/repositories/snapshots/commons-net/commons-net/3.0.1-SNAPSHOT/
这篇关于FTPClient 在上传到 android 上的 ftp 服务器时损坏图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!