1

我正在尝试使用 Apache commons-net FTP 库将大文件 (>100Mb) 上传到 Secure FTP Server IIS。

这是我的代码:

try{
ftpClient = new FTPSClient("TLS", false);
        this.ftpClient.setDataTimeout(6000000);
        this.ftpClient.setConnectTimeout(6000000);
        ftpClient.connect(host, port);
        ftpClient.login(userName, password);
            ftpClient.enterLocalPassiveMode();
         if (ftpClient.getReplyCode() == 230){
               ftpClient.sendCommand("OPTS UTF8 ON");
               ftpClient.execPBSZ(0);
               ftpClient.execPROT("P");
         else{
             throw new Exception("connection failed.....");}
         ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        InputStream is= new FileInputStream("C:\\movie.avi");
         ftpClient.setUseEPSVwithIPv4(true);
             ftpClient.storeFile(remotePath, is);
         is.close();
       }
         catch (SocketException e) {
    e.printStackTrace();
        } catch (IOException e) {
    e.printStackTrace();
        }

它无法上传大于 19Mb 的文件。storeFile 方法抛出IOException空的 StackTrace。您可以看到以下IOException变量:

   e    CopyStreamException  (id=39)    
    cause   CopyStreamException  (id=39)    
    detailMessage   "IOException caught while copying." (id=45) 
    ioException SocketException  (id=46)    
        cause   SocketException  (id=46)    
        detailMessage   "Connection reset by peer: socket write error" (id=50)  
        stackTrace  null    
    stackTrace  null    
    totalBytesTransferred   19084288    

实际上它的行为如下:

1)当我开始上传时,创建了零大小的文件,而我正在上传文件大小仍然为零并且发生异常时,这个空文件被FTP删除。

2) 有趣的是 FileZila 也无法上传这些文件,但其限制大小为 70Mb。

我错过了什么吗?

4

1 回答 1

1

好。很遗憾,防火墙引起的问题,在 5 分钟超时后关闭了数据端口。

于 2012-01-05T07:25:50.713 回答