2012-07-15 28 views
0
byte[] fileItemData = blobstoreService.fetchData(blobKey, 0, 999999); 
ByteArrayContent mediaContent = new ByteArrayContent(fileItemMimeType, fileItemData); 
insert = driveService.files().insert(body, mediaContent); 
File file = insert.execute(); 

- >爲什麼insert.execute()不能捕獲異常...?什麼都不做。 - >當我離開「fileItemData」我得到一個項目在谷歌驅動器。那麼它有什麼問題?我正嘗試將其上傳到Google AppEngine並存儲到AppEngine上的Google Drive。從AppEngine Java保存字節[]到Google Drive

+0

我很困惑,什麼是錯的 - 你在'insert.execute()'上得到一個異常?當你「離開」'fileItemData'時,你是什麼意思得到一個項目? – 2012-07-16 09:56:37

+0

如果我插入沒有fileItemData - 對不起,我應該說mediaContent - >插入= driveService.files()。插入(身體); <我會看到在谷歌驅動器 – Malte 2012-07-16 18:55:49

+0

條目我沒有得到一個例外......只是什麼都沒有發生時用mediacontent插入。 – Malte 2012-07-16 18:56:30

回答

1

你能盡你的代碼與一個較小的數據,比如這個:

ByteArrayContent mediaContent = ByteArrayContent.fromString("text/plain", "Hello World") 
driveService.files().insert(body, mediaContent).execute(); 

,讓我知道是否可行?

+0

沒有工作。 行插入...後跟一個日誌只有當我執行.insert(body).execute()'(下一行執行日誌)代替'.insert(body,mediaContent).execute() )' >(下一行日誌未執行,appeEngine上沒有錯誤日誌)。 使用'.insert(body).execute()'創建一個沒有內容的完美谷歌驅動器條目。 Google雲端硬盤正如預期所示: >「對不起,我們無法在原始來源找到該文檔。」 >確認文檔仍然存在。「 。 – Malte 2012-07-17 07:34:36

+0

我的猜測是發生了一個沒有捕獲到的異常。你嘗試圍繞呼叫嘗試{...}緩存(例外e){/ /寫e.getMessage()記錄}? – Nivco 2012-07-17 11:06:42

+0

它被包圍: }趕上(GoogleJsonResponseException E){ }趕上(HttpResponseException E){ }趕上(IOException的發送){ }趕上(例外五){ – Malte 2012-07-17 14:50:59