简体   繁体   English

Apache Commons-net FTP-将文件上传到安全FTP IIS

[英]Apache commons-net FTP - uploading file to Secure FTP IIS

I'm trying to upload large file (>100Mb) using Apache commons-net FTP library to Secure FTP Server IIS. 我正在尝试使用Apache commons-net FTP库将大文件(> 100Mb)上传到Secure FTP Server IIS。

Here is my code: 这是我的代码:

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

It fails to upload files larger then 19Mb. 无法上传大于19Mb的文件。 storeFile methods throws IOException with empty StackTrace. storeFile方法使用空StackTrace引发IOException You can see below IOException variables: 您可以在下面看到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    

Actually it behaves the following way: 实际上,它的行为方式如下:

1) when I'm starting upload, zero size file created, while I'm uploading file size is still zero and when the exception occurs, this empty file removed by FTP. 1)当我开始上传时,创建的文件大小为零,而我上传的文件大小仍为零,并且当发生异常时,此空文件被FTP删除。

2) funny thing is that FileZila fails to upload these files as well, but its limit size is 70Mb. 2)有趣的是FileZila也无法上传这些文件,但其限制大小为70Mb。

Am I missing something? 我想念什么吗?

Well. 好。 Sad by true, the problem caused by firewall, which closed Data port after 5 minutes time out. 真遗憾,这是防火墙引起的问题,防火墙在5分钟超时后关闭了数据端口。

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

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