2014-11-15 4 views
2

나는 Google 드라이브에 일부 데이터를로드 할 수 있습니다,하지만 난 recommended by Drive SDK way to do it를 사용할 수 없습니다 내 데이터는 항상 아닌 소스로 java.io.File에있다Drive SDK의 InputStream에서 Google 드라이브로 파일을 업로드 할 수 있나요?

FileContent fileContent = new FileContent(mimeType, dataFile); 
try { 
    File file = service.files().insert(body, fileContent).execute(); 
    return file; 
} catch (IOException e) { 
    System.out.println("An error occured: " + e); 
    return null; 
} 

때문이다. 때로는 암호화 된 저장소 나 다른 클라우드 저장소에서 가져온 InputStream 일 수 있으므로 FileContent를 가져올 수 없습니다. 중간에 파일 시스템에 저장하지 않고 InputStream에서 Google 드라이브로 데이터를로드하는 방법이 있습니까 (예 : Dropbox API method "putFileOverwrite")? 밖으로

답변

2

확인이

File file= drive.files().insert(body, 
           new InputStreamContent(
             fileItemStream 
               .getContentType(), 
             new ByteArrayInputStream(
               IOUtils.toByteArray(fileInputStream)))).execute; 
관련 문제