2014-10-01 4 views
0

안녕하세요 weed-fs java client을 사용하여 weed-fs에 파일을 업로드하려고합니다. 나는 of how to install weed 지침에 따라 성공적으로 잡초를 설치했다고 생각합니다. 짧은 Iweed-fs에 파일을 업로드하는 방법

  1. 에서 명령 $./weed master
  2. 모든 명령`$와 폴더를 업로드하여 작동하는지 다음 $./weed volume -port=9444 내 응용 프로그램 서버와 볼륨 서버가 이미 점유 포트 8080
  3. 테스트와 함께 마스터를 시작합니다./대마초 업로드 -dir = "any_dir_with_small_files"

이 시점까지는 모두 정상입니다. 내 응용 프로그램에서 나는 업로드를 처리 할 클래스를 호출하는 서블릿에 의해 가로 챈 브라우저에서 multipart/form-data을 게시하려고 시도합니다. 나는이 프로그램을 실행할 때

public void upload(HttpServletRequest request) throws FileUploadException, IOException { 
    client = new WeedFSClient(MASTER_ADDRESS, MASTER_PORT); 
    if (ServletFileUpload.isMultipartContent(request)) { 
     FileItemIterator fileItemIterator = new ServletFileUpload().getItemIterator(request); 
     InputStream inputStream = null; 
     while (fileItemIterator.hasNext()) { 
      FileItemStream item = fileItemIterator.next(); 
      if (!item.isFormField()) { 
       inputStream = item.openStream(); 
       File file = new File(request.getServletContext().getRealPath("/")+"img/uploads/"+item.getName()); 
       FileOutputStream fos = new FileOutputStream(file); 
       Streams.copy(inputStream, fos, true); 
       RequestResult result = client.upload(file); 
       if (result.isSuccess()) { 
        System.out.println("uploaded file with ID "+result.getFid()); 
       } 
      } 
     } 
    } 
} 

나는이 같은 X10에 대해 다음과 같이 계속 디버그 정보

Info: DEBUG - Get connection for route {}->http://localhost:9444 
Info: DEBUG - Connecting to localhost:9444 
Info: DEBUG - CookieSpec selected: best-match 
Info: DEBUG - Auth cache not set in the context 
Info: DEBUG - Target auth state: UNCHALLENGED 
Info: DEBUG - Proxy auth state: UNCHALLENGED 
Info: DEBUG - Attempt 1 to execute request 
Info: DEBUG - Sending request: POST /2,ace132597a HTTP/1.1 
Info: DEBUG - >> "POST /2,ace132597a HTTP/1.1[\r][\n]" 
Info: DEBUG - >> "Transfer-Encoding: chunked[\r][\n]" 
Info: DEBUG - >> "Content-Type: multipart/form-data; boundary=TVf_3Jwe1DSTTHoUnZcyiA5KCVUFixPeItY3[\r][\n]" 
Info: DEBUG - >> "Host: localhost:9444[\r][\n]" 
Info: DEBUG - >> "Connection: Keep-Alive[\r][\n]" 
Info: DEBUG - >> "User-Agent: Apache-HttpClient/4.2.5 (java 1.5)[\r][\n]" 
Info: DEBUG - >> "[\r][\n]" 
Info: DEBUG - >> POST /2,ace132597a HTTP/1.1 
Info: DEBUG - >> Transfer-Encoding: chunked 
Info: DEBUG - >> Content-Type: multipart/form-data; boundary=TVf_3Jwe1DSTTHoUnZcyiA5KCVUFixPeItY3 
Info: DEBUG - >> Host: localhost:9444 
Info: DEBUG - >> Connection: Keep-Alive 
Info: DEBUG - >> User-Agent: Apache-HttpClient/4.2.5 (java 1.5) 
Info: DEBUG - >> "1088[\r][\n]" 
Info: DEBUG - >> "--TVf_3Jwe1DSTTHoUnZcyiA5KCVUFixPeItY3[\r][\n]" 
Info: DEBUG - >> "Content-Disposition: form-data; name="fileBody"; filename="23.jpg"[\r][\n]" 
Info: DEBUG - >> "Content-Type: text/plain[\r][\n]" 
Info: DEBUG - >> "[\r][\n]" 
Info: DEBUG - >> "[0xff][0xd8][0xff][0xe0][0x0][0x10]JFIF[0x0][0x1][0x1][0x1][0x0]H[0x0]H[0x0][0x0][0xff][0xe1][0x16][0xf2]Exif[0x0][0x0]II*[0x0][0x8][0x0][0x0][0x0][0x17][0x0][0x0][0x1][0x3][0x0][0x1][0x0][0x0][0x0][0x90][0x6][0x0][0x0][0x1][0x1][0x3][0x0][0x1][0x0][0x0][0x0][0x1a][0x4][0x0][0x0][0x2][0x1][0x3][0x0][0x3][0x0][0x0][0x0]"[0x1][0x0][0x0][0x6][0x1][0x3][0x0][0x1][0x0][0x0][0x0][0x2][0x0][0x0][0x0][0xf][0x1][0x2][0x0][0x6][0x0][0x0][0x0]([0x1][0x0][0x0][0x10][0x1][0x2][0x0][0x15][0x0][0x0][0x0].[0x1][0x0][0x0][0x12][0x1][0x3][0x0][0x1][0x0][0x0][0x0][0x1][0x0][0x0][0x0][0x15][0x1][0x3][0x0][0x1][0x0][0x0][0x0][0x3][0x0][0x0][0x0][0x1a][0x1][0x5][0x0][0x1][0x0][0x0][0x0]D[0x1][0x0][0x0][0x1a][0x1][0x5][0x0][0x1][0x0][0x0][0x0]L[0x1][0x0][0x0][0x1b][0x1][0x5] 

많이 얻을 내 화면 나는 매우 작은 글꼴 크기를 설정 잊으 신 건 아니의 높이. 다른 사람이 어떻게해야하는지 알려주세요. 그리고 당신이 나를 잡초 fs에 대한 자바 클라이언트에 대한 적절한 가이드로 인도 할 수 있다면 나는 또한 그것을 고맙게 생각할 것입니다. 미리 감사드립니다.

답변

0

제대로하고있는 것처럼 보입니다. 디버깅 메시지를 보지 않으려면 디버깅 메시지를 끄십시오.

+0

당신은 weed-fs 분산 파일 저장소의 저자입니까? – qualebs

+0

"당신은 weed-fs 분산 파일 저장소의 저자입니다."그렇습니다. – chrislusf

+0

안녕하세요 Chris 저는 거의 1 년 동안 내 사이트에서 잡초를 사용하고 있습니다. 왜 사용자 이름을 바꿨습니까? 당신을 찾기가 약간 어려웠습니까? github 또는 새로운 사용자와 노련한 잡초 사용자 (말장난 없음)가 상호 작용할 수있는 곳의 잡초 - fs 프로젝트를위한 Q & A 섹션이 있었으면 좋겠습니다. 이 일을 할 수 있다고 생각합니까? 이슈 트래커 페이지는 이슈와 버그를 추적하는 데 유용하지만 다른 사람들은 문제가 아닌 문제가있을 수 있습니다. – qualebs

관련 문제