2012-08-14 83 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

相关问题