2012-03-22 6 views
1

FTPClient의 storeFile (원격, 로컬) 메소드를 사용하여 하나의 대용량 파일 (8MB 이상)을 업로드하려고하지만 오류가 발생합니다. 업로드됩니다. 출력은 다음과 같습니다.Apache commons-net-3.1을 사용하여 FTP에 대용량 파일을 업로드 할 수 없습니다.

public class Main { 
public static void main(String[] args) { 
FTPClient client = new FTPClient(); 
FileInputStream fis = null; 

try { 

client.connect("208.106.181.143"); 
client.setFileTransferMode(client.BINARY_FILE_TYPE); 
client.login("abc", "java"); 
int reply = client.getReplyCode(); 
System.out.println("Received Reply from FTP Connection:" + reply); 

if(FTPReply.isPositiveCompletion(reply)){ 
    System.out.println("Connected Success"); 
} 

client.changeWorkingDirectory("/"+"Everbest"+"/"); 
client.makeDirectory("ETPSupplyChain5.3-EvbstSP3"); 
client.changeWorkingDirectory("/"+"Everbest"+"/"+"ETPSupplyChain5.3-EvbstSP3"+"/"); 
FTPFile[] names = client.listFiles(); 
String filename = "E:\\Nitin\\D-Drive\\Installer.rar"; 

fis = new FileInputStream(filename); 

boolean result = client.storeFile("Installer.rar", fis); 
int replyAfterupload = client.getReplyCode(); 
System.out.println("Received Reply from FTP Connection replyAfterupload:" + replyAfterupload); 
System.out.println("result:"+result); 
for (FTPFile name : names) { 
    System.out.println("Name = " + name); 
    } 

client.logout(); 

fis.close(); 



client.disconnect(); 
} catch (SocketException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
} 
} 




o/p: 
Received Reply from FTP Connection:230 
Connected Success 
32 /Everbest/ETPSupplyChain5.3-EvbstSP3 
Received Reply from FTP Connection replyAfterupload:150 
result:false 
+0

안녕하세요, FTPClient의 storeFile (원격, 로컬) 메소드가 FTP에 파일 업로드를위한 크기 제한이 있다면 알려 주시기 바랍니다. – Nitin

답변

0

먼저 8MB 파일은 큰 파일이 아닙니다. 이 라이브러리를 사용하여 100MB보다 큰 파일을 업로드 할 수있었습니다.

storeFile 메서드 앞에 BINARY_FILE_TYPE 메서드를 호출하여 setFileType 메서드를 호출하십시오. 그것은 서버에 파일을 ASCII로 저장하면 안된다고 알려줍니다.

마지막으로 storeFile 메서드 바로 다음에 FileInputStream을 닫으십시오. 그리고 close 방법의 결과를 잡아라.