我可以使用Google SDK将文件上传到Google云端硬盘。但是我收到的回复中没有“thumbnailLink”字段。
我想为通过我的应用程序上传的每个文件显示预览图像。我该怎么办呢?
这是我的请求代码:
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 :(得分:4)
缩略图创建过程是异步的,因此thumbnailLink
字段不包含在文件上载调用返回的元数据中。尝试在等待一小段时间后检索同一文档,它应该包含该字段。