0
我正嘗試使用outputstream
將文件上傳到Google雲端硬盤。隨着下載我能夠得到InputStream
這樣:使用輸出流將文件上傳到Google雲端硬盤
public void downloadStarted() throws Exception
{
HttpResponse resp = drive.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())).execute();
serverInputStream = resp.getContent();
}
有關上載我有一個工作的這個樣本測試:
private static File uploadFile(boolean useDirectUpload) throws IOException
{
File fileMetadata = new File();
fileMetadata.setTitle(UPLOAD_FILE.getName());
FileContent mediaContent = new FileContent("*/*", UPLOAD_FILE);
Drive.Files.Insert insert = drive.files().insert(fileMetadata, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(useDirectUpload);
uploader.setProgressListener(new FileUploadProgressListener());
return insert.execute();
}
,但我真的需要outputstream
,而且不知道如何得到它。任何幫助?