2012-08-14 85 views
1

我可以使用Google SDK將文件上傳到Google雲端硬盤。但我收到的回覆不包含「thumbnailLink」字段。如何獲取上傳到Google雲端硬盤的PDF版本?

我想顯示通過我的應用程序上傳的每個文件的預覽圖像。我該怎麼辦?

這裏是我的請求代碼:

File driveFile = new File(); 
driveFile.setTitle("File Title"); 
driveFile.setMimeType(userFile.getContentType()); 

FileContent driveFileContent = new FileContent(userFile.getContentType(), userFile.asFile());     
File insertedDriveFile = driveService.files().insert(driveFile, driveFileContent).setConvert(true).execute(); 

,這裏是我的迴應:

{ 
    "alternateLink" : "https://docs.google.com/file/d/...", 
    "createdDate" : { 
     "dateOnly" : false, 
     "tzShift" : 0, 
     "value" : 1345031115877 
    }, 
    "description" : "Some Text", 
    "downloadUrl" : "...", 
    "editable" : true, 
    "etag" : "\"qZporUffWgr4KlPui79y_IN18w8/MTM0NTAzMTExNjI1OA\"", 
    "fileExtension" : "", 
    "fileSize" : 15666, 
    "id" : "0B4FbUv8OusD1Q3V2aFM2M2pVaEk", 
    "kind" : "drive#file", 
    "labels" : { "hidden" : false, 
     "restricted" : false, 
     "starred" : false, 
     "trashed" : false, 
     "viewed" : true 
    }, 
    "lastModifyingUserName" : "Regis Bamba", 
    "lastViewedByMeDate" : { "dateOnly" : false, 
    "tzShift" : 0, 
    "value" : 1345031115769 
    }, 
    "md5Checksum" : "0baac1165bd1a004fa52eb9777e455df", 
    "mimeType" : "application/pdf", 
    "modifiedByMeDate" : { "dateOnly" : false, 
     "tzShift" : 0, 
     "value" : 1345031116258 
     }, 
    "modifiedDate" : { "dateOnly" : false, 
     "tzShift" : 0, 
     "value" : 1345031116258 
     }, 
    "originalFilename" : "Test File", 
    "ownerNames" : [ "Regis" ], 
    "parents" : [ { "id" : "0AIFbUv8OusD1Uk9PVA", 
      "isRoot" : true, 
      "kind" : "drive#parentReference", 
      "parentLink" : "...", 
    "selfLink" : "..." 
    } ], 
    "quotaBytesUsed" : 15666, 
    "selfLink" : "...", 
    "title" : "Test File", 
    "userPermission" : { "etag" : "\"qZporUffWgr4KlPui79y_IN18w8/S0oJPFvxJQWU-e8QPUGRAAa4JaA\"", 
    "id" : "me", 
    "kind" : "drive#permission", 
    "role" : "owner", 
    "selfLink" : "https://www.googleapis.com/drive/v2/files/0B4FbUv8OusD1Q3V2aFM2M2pVaEk/permissions/me", 
    "type" : "user" 
}, 
    "webContentLink" : "https://docs.google.com/uc?id=0B4FbUv8OusD1Q3V2aFM2M2pVaEk&export=download", 
    "writersCanShare" : true 
    }  

感謝

+0

你能告訴我們你的要求和迴應嗎?我剛剛嘗試使用OAuth Playground,並將縮略圖返回爲pdf。 – 2012-08-14 17:08:57

+0

嗨克勞迪奧,我剛剛嘗試過OAuth Playground和一個PDF,它也沒有返回縮略圖。但我會根據我的要求和回覆更新這個問題。 – Regis 2012-08-15 11:35:46

回答

4

縮略圖創建過程是異步的,因此thumbnailLink字段不包括在由文件上傳調用返回的元數據。嘗試在稍等一會兒之後檢索相同的文檔,它應該包含該字段。

+0

你是對的!非常感謝你!! – Regis 2012-08-15 20:29:29

相關問題