問(wèn)題描述
我正在嘗試從 Android 手機(jī) (HTC Desire HD) 將圖像上傳到 FTP 服務(wù)器(在我的本地 PC 上).圖像將發(fā)送到 FTP 服務(wù)器,但它們已損壞.
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)
請(qǐng)幫幫我.
這是損壞的圖片鏈接:
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();
}
推薦答案
問(wèn)題解決了.FTPClient 類(lèi)有最后一個(gè)數(shù)據(jù)包數(shù)據(jù)丟失錯(cuò)誤".但這已通過(guò) 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.
你可以從關(guān)于bug的詳細(xì)解釋中看到: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/
這篇關(guān)于FTPClient 在上傳到 android 上的 ftp 服務(wù)器時(shí)損壞圖像?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!