FtpClient的破坏了图像,同时上传到FTP服务器上的Andr​​oid? [英] FTPClient corrupts the images while uploading to ftp server on android?

查看:253
本文介绍了FtpClient的破坏了图像,同时上传到FTP服务器上的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上传图片到从Android手机(HTC Desire HD的)一个FTP服务器(本地PC上)。图像将FTP服务器,但它们已损坏。

和方法(ftpClient.storeFile())抛出IOException异常(错误的文件数)

请帮我。

这是已损坏的图像链接:

<一个href="http://imageshack.us/photo/my-images/820/komikb.jpg/">http://imageshack.us/photo/my-images/820/komikb.jpg/

这是code:

  FtpClient的FtpClient的=新FtpClient的();
    尝试 {
        ftpClient.connect(192.168.2.14);
        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
        ftpClient.setSoTimeout(10000);
        ftpClient.enterLocalPassiveMode();
        如果(ftpClient.login(管理员,XXXX))
        {
            文件sFile =新的文件(MNT / SD卡/ DCIM / komik.jpg);
            的FileInputStream FS =新的FileInputStream(sFile);
            字符串文件名= sFile.getName();
            布尔结果= ftpClient.storeFile(/ ftpfile.atspace.co.uk/+文件名,FS);
            字符串有=;
        }
    }赶上(IOException异常E){
        // TODO自动生成的catch块
        e.printStackTrace();
    }
 

解决方案

问题就解决了​​。 FtpClient的类有最后一个数据包的数据丢失的错误。但是,这是解决了3.0.1 2011年5月23日发布。

您可以从有关错误的详细说明,请参阅: https://issues.apache.org/jira/browse/NET-409

您可以下载固定relea <一href="https://repository.apache.org/content/repositories/snapshots/commons-net/commons-net/3.0.1-SNAPSHOT/" rel="nofollow">https://repository.apache.org/content/repositories/snapshots/commons-net/commons-net/3.0.1-SNAPSHOT/

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.

And the method (ftpClient.storeFile()) throws IOException (Bad File Number)

Please help me.

This is the corrupted image link:

http://imageshack.us/photo/my-images/820/komikb.jpg/

And this is the code:

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();
    }

解决方案

Problem is solved. FTPClient class has "last packet data loss bug". But this was solved with 3.0.1 23.05.2011 release.

You can see from detailed explanation about bug: https://issues.apache.org/jira/browse/NET-409

You can download fixed relea https://repository.apache.org/content/repositories/snapshots/commons-net/commons-net/3.0.1-SNAPSHOT/

这篇关于FtpClient的破坏了图像,同时上传到FTP服务器上的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆