1

我可以使用 Google SDK 将文件上传到 Google Drive。但我收到的回复不包含“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
  }      

谢谢

4

1 回答 1

4

缩略图创建过程是异步的,因此该thumbnailLink字段不包含在文件上传调用返回的元数据中。稍等片刻后尝试检索相同的文档,它应该包含该字段。

于 2012-08-15T16:06:17.700 回答