简体   繁体   English

Apache Commons Net慢速FTP上传

[英]Apache Commons Net Slow FTP Upload

I'm using Apache Commons Net 3.3 to handle FTP transfers in a Java application. 我正在使用Apache Commons Net 3.3来处理Java应用程序中的FTP传输。

Downloads seem to work fine, but I'm getting speeds a lot slower than the local internet connection capabilities for uploads. 下载似乎可以正常工作,但是速度比本地互联网连接功能慢得多。

The code that writes the file data to the stream looks like this: 将文件数据写入流的代码如下所示:

        BufferedOutputStream out = new BufferedOutputStream(ftp.getOutputStream(prt));
        BufferedInputStream in = new BufferedInputStream(prov.getInputStream(s));
        byte[] buff = new byte[BUFF_SIZE];
        int len;
        while ((len = in.read(buff)) >= 0 && !prog.isCanceled()) {
            out.write(buff, 0, len);
            total += len;
            prog.setProgress((int) (Math.round((total / combo) * 100)));
        }

        in.close();
        out.close();

BUFF_SIZE = 16kB BUFF_SIZE = 16kB

I have the FTPClient buffer size also set to 16kB via setBufferSize 我也通过setBufferSize将FTPClient缓冲区大小设置为16kB

The issue isn't with the server or my internet connection because the upload proceeds at a much more reasonable speed using Filezilla as a FTP client. 问题不在于服务器或我的互联网连接,因为使用Filezilla作为FTP客户端,上传速度更快。

The issue also seems to occur with Java 6 and 7 JVMs. Java 6和7 JVM似乎也出现此问题。

Does anyone have any ideas as to why this is happening? 有谁知道为什么会这样吗? Is there a problem with Commons Net or Java? Commons Net或Java是否有问题? Or is there something I haven't configured correctly? 还是我没有正确配置某些内容?

Same problem - using SDK 1.6 resolve problem, but also try to find better way 同样的问题-使用SDK 1.6解决问题,但也尝试寻找更好的方法

UPD: Solved (see comments) UPD:已解决(请参阅评论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM